<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Suhail Kakar on Medium]]></title>
        <description><![CDATA[Stories by Suhail Kakar on Medium]]></description>
        <link>https://medium.com/@suhailkakar?source=rss-62c589bb40e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RtLXHb_hqMC2wWbquoleaw.jpeg</url>
            <title>Stories by Suhail Kakar on Medium</title>
            <link>https://medium.com/@suhailkakar?source=rss-62c589bb40e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:59:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suhailkakar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create a React Native Ecommerce App with Medusa Part 2: Adding Cart and Checkout]]></title>
            <link>https://medium.com/medusa-commerce/create-a-react-native-ecommerce-app-with-medusa-part-2-adding-cart-and-checkout-fcf03ab79b4d?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcf03ab79b4d</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 10:39:59 GMT</pubDate>
            <atom:updated>2022-10-07T10:39:59.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7YZRqcCrSzH1v2FK7SLgA.jpeg" /></figure><p>Medusa is currently hosting a <a href="https://medusajs.com/blog/medusa-hackathon-warming-up-for-hacktoberfest/">Hackathon</a> where developers can create amazing projects with Medusa and win prizes and swag. An example of a Hackathon project is building an ecommerce app with React Native, which is covered in this article.</p><p>This is part 2 of <strong>Creating a React Native ecommerce App with Medusa</strong> series. In the previous article, you learned how to set up the Medusa server and admin, and how to create a basic ecommerce app.</p><p>In this part, you will learn how to implement cart and checkout functionalities. You can also find the source code of the React Native app on <a href="https://github.com/suhailkakar/react-native-medusajs"><strong>GitHub</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*rUCGuk_wNbUjpz85smYDxg.gif" /></figure><h3>Prerequisites</h3><ul><li>You need a Stripe account, you can signup <a href="https://dashboard.stripe.com/register">here</a>.</li></ul><h4>Clone the Starter Code</h4><p>If you skipped part 1, you can clone the code from GitHub. To do that, simply run the below command:</p><pre>git clone -b part-1 <a href="https://github.com/suhailkakar/react-native-medusajs">https://github.com/suhailkakar/react-native-medusajs</a></pre><p>Once you have cloned the repository, move to the newly-created directory, react-native-medusajs, by running cd react-native-medusajs. Run the below command to install the node modules:</p><pre>yarn install</pre><p>The above command will install the necessary packages and dependencies from the NPM registry.</p><p>After the dependencies are installed successfully, run expo start to start the application. You can either scan the QR code using your device or run the app on an Android/iOS simulator. You should see a similar screen once the app is opened on your device/emulator.</p><blockquote><em>Make sure that the Medusa server is running as well.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*kqPkL-_WlIxQOx5H.png" /></figure><p>You might need to modify the URL in constants/urls.js if you can&#39;t see the products. You can update the base URL to the IP address where the backend server is running.</p><h3>Creating the Cart</h3><p>The first step is to implement the cart functionality. Install async-storage to save the cart id in the device’s local storage. Run the below command to install @react-native-async-storage/async-storage in the project:</p><pre>expo install @react-native-async-storage/async-storage</pre><p>Once the package is installed, open the project in any code editor and paste the below code into App.js before the return function:</p><pre>const getCartId = () =&gt; {<br>    axios.post(`${baseURL}/store/carts`).then((res) =&gt; {<br>      AsyncStorage.setItem(&quot;cart_id&quot;, res.data.cart.id);<br>    });<br>  };</pre><p>In the above code, you created a function named getCartId and inside of that function, you are querying the backend API to get a cart id using Axios and then saving it in the device’s local storage using async-storage.</p><blockquote><em>Make sure to import async-storage, useEffect, Axios and baseURL in the </em><em>App.js file:</em></blockquote><pre>import axios from &quot;axios&quot;;<br>import baseURL from &quot;./constants/url&quot;;<br>import { useEffect } from &quot;react&quot;;<br>import AsyncStorage from &quot;@react-native-async-storage/async-storage&quot;;</pre><p>The above function (getCartId) will not run since you didn’t call it yet. However, you want to run this function only if there is no cart id saved in the device’s local storage.</p><p>Now, write another function to check if there’s already a cart id in the device’s local storage. If there isn’t, the function should call getCartId. Lastly, call the checkCartId inside of useEffect:</p><pre>// Check cart_id <br>  const checkCartId = async () =&gt; {<br>    const cartId = await AsyncStorage.getItem(&quot;cart_id&quot;);<br>    if (!cartId) {<br>      getCartId();<br>    }<br>  };</pre><pre>useEffect(() =&gt; {<br>    checkCartId();<br>}, []);</pre><h4>Adding Products to the Cart</h4><p>First, let’s update the button component and add a prop to update the button layout based on the size provided. You can replace the code inside components/Button.js with the code below:</p><pre>import { View, Text, StyleSheet } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;<br>import { widthToDp } from &quot;rn-responsive-screen&quot;;</pre><pre>export default function Button({ title, onPress, style, textSize, large }) {<br>  return (<br>    &lt;View style={[styles.container, style, large &amp;&amp; styles.large]}&gt;<br>      &lt;Text<br>        style={[<br>          styles.text,<br>          { fontSize: textSize ? textSize : widthToDp(3.5) },<br>          ,<br>        ]}<br>        onPress={onPress}<br>      &gt;<br>        {title}<br>      &lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    backgroundColor: &quot;#C37AFF&quot;,<br>    padding: 5,<br>    width: widthToDp(20),<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>    borderRadius: 59,<br>  },<br>  large: {<br>    width: &quot;100%&quot;,<br>    marginTop: 10,<br>    height: widthToDp(12),<br>  },<br>  text: {<br>    color: &quot;#fff&quot;,<br>    fontWeight: &quot;bold&quot;,<br>  },<br>});</pre><p>Recall that by the end of Part 1, you have created a component at components/ProductInfo/MetaInfo.js to display the description, size, and other information about the product. Go ahead and add a button component after the description:</p><pre>&lt;Button title=&quot;Add to Cart&quot; onPress={addToCart} large={true} /&gt;</pre><p>Also, make sure to import the button component from components/Button:</p><pre>import Button from &quot;../Button&quot;;</pre><p>As you can see, you are calling addToCart function when the user presses the button, so declare that function.</p><p>On top of MetaInfo.js component before return, declare a new function named addToCart and add the below code inside of it:</p><pre>const addToCart = async () =&gt; {<br>    const cartId = await AsyncStorage.getItem(&quot;cart_id&quot;);<br>    axios<br>      .post(`${baseURL}/store/carts/${cartId}/line-items`, {<br>        variant_id: product.variants[0].id,<br>        quantity: 1,<br>      })<br>      .then(({ data }) =&gt; {<br>        alert(`Item ${product.title} added to cart`);<br>      })<br>      .catch((err) =&gt; {<br>        console.log(err);<br>      });<br>  };</pre><p>In the above code, first, you are fetching the cart_id from async storage and then posting the product’s first variant with 1 quantity to the cart API. Next, you are navigating users to the cart screen.</p><p>You also need to import AsyncStorage, axios and baseURL in the MetaInfo.js file:</p><pre>import axios from &quot;axios&quot;;<br>import baseURL from &quot;../../constants/url&quot;;<br>import AsyncStorage from &quot;@react-native-async-storage/async-storage&quot;;</pre><h4>Cart Screen</h4><p>This is the screen where the user will see the products they added to the cart. Create a new file named screens/Cart.js and use it to render a simple <strong>Text</strong> component for now:</p><pre>import { View, Text } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;</pre><pre>export default function Cart() {<br>  return (<br>    &lt;View&gt;<br>      &lt;Text&gt;Cart Screen&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><p>Then, import the cart screen at the top of <strong>App.js</strong>:</p><pre>import Cart from &quot;./screens/Cart&quot;;</pre><p>Add a new <strong>Scene</strong> component below the existing <strong>Scene</strong> component in the returned JSX:</p><pre>&lt;Scene key=&quot;cart&quot; component={Cart} hideNavBar /&gt;</pre><p>In the <strong>components</strong> directory, create a new file named CartItem.js and add the following content:</p><pre>import { View, Text, StyleSheet, Image } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;<br>import { heightToDp, width, widthToDp } from &quot;rn-responsive-screen&quot;;</pre><pre>export default function CartItem({ product }) {<br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;Image source={{ uri: product.thumbnail }} style={styles.image} /&gt;<br>      &lt;View style={styles.info}&gt;<br>        &lt;View&gt;<br>          &lt;Text style={styles.title}&gt;{product.title}&lt;/Text&gt;<br>          &lt;Text style={styles.description}&gt;<br>            {product.description} • ${product.unit_price / 100}<br>          &lt;/Text&gt;<br>        &lt;/View&gt;<br>        &lt;View style={styles.footer}&gt;<br>          &lt;Text style={styles.price}&gt;${product.total / 100}&lt;/Text&gt;<br>          &lt;Text style={styles.quantity}&gt;x{product.quantity}&lt;/Text&gt;<br>        &lt;/View&gt;<br>      &lt;/View&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    marginTop: 20,<br>    flexDirection: &quot;row&quot;,<br>    borderBottomWidth: 1,<br>    paddingBottom: 10,<br>    borderColor: &quot;#e6e6e6&quot;,<br>    width: widthToDp(&quot;90%&quot;),<br>  },<br>  image: {<br>    width: widthToDp(30),<br>    height: heightToDp(30),<br>    borderRadius: 10,<br>  },<br>  title: {<br>    fontSize: widthToDp(4),<br>    fontWeight: &quot;bold&quot;,<br>  },<br>  footer: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;space-between&quot;,<br>  },<br>  info: {<br>    marginLeft: widthToDp(3),<br>    flexDirection: &quot;column&quot;,<br>    justifyContent: &quot;space-between&quot;,<br>    marginVertical: heightToDp(2),<br>    width: widthToDp(50),<br>  },<br>  description: {<br>    fontSize: widthToDp(3.5),<br>    color: &quot;#8e8e93&quot;,<br>    marginTop: heightToDp(2),<br>  },</pre><pre>  price: {<br>    fontSize: widthToDp(4),<br>  },<br>  quantity: {<br>    fontSize: widthToDp(4),<br>  },<br>});</pre><p>The above code is a simple React Native cart component which will be rendered on the cart screen. You are passing the props to the component from the parent component. This is the component that will represent an item in the cart.</p><p>Next, in the screens/Cart.js file, add the below function and useState before the return statement to fetch the products from the cart API and store them in the state:</p><pre>const [cart, setCart] = useState([]);</pre><pre>  const fetchCart = async () =&gt; {<br>    // Get the cart id from the device storage<br>    const cartId = await AsyncStorage.getItem(&quot;cart_id&quot;);<br>    // Fetch the products from the cart API using the cart id<br>    axios.get(`${baseURL}/store/carts/${cartId}`).then(({ data }) =&gt; {<br>      // Set the cart state to the products in the cart<br>      setCart(data.cart);<br>    });<br>  };</pre><pre>  useEffect(() =&gt; {<br>        // Calling the fetchCart function when the component mounts<br>    fetchCart();<br>  }, []);</pre><p>In the above code, you are getting the cart id from the device storage, fetching the products from the cart API and saving the data to the state. Next, you are calling the function inside of useEffect. Replace the import at the top of the screens/Cart.js file with the code below:</p><pre>import { View, Text, StyleSheet } from &quot;react-native&quot;;<br>import React, { useEffect, useState } from &quot;react&quot;;<br>import Header from &quot;../components/Header&quot;;<br>import axios from &quot;axios&quot;;<br>import baseURL from &quot;../constants/url&quot;;<br>import CartItem from &quot;../components/CartItem&quot;;<br>import { ScrollView } from &quot;react-native-gesture-handler&quot;;<br>import { SafeAreaView } from &quot;react-native-safe-area-context&quot;;<br>import { width, widthToDp } from &quot;rn-responsive-screen&quot;;<br>import Button from &quot;../components/Button&quot;;<br>import { Actions } from &quot;react-native-router-flux&quot;;<br>import AsyncStorage from &quot;@react-native-async-storage/async-storage&quot;;</pre><p>Now that you have fetched the data and saved it to the state, it’s time to render the products on the cart screen. Replace everything below useEffect function with the below code:</p><pre>return (<br>    // SafeAreaView is used to avoid the notch on the phone<br>    &lt;SafeAreaView style={[styles.container]}&gt;<br>      {/* SchrollView is used in order to scroll the content */}<br>      &lt;ScrollView contentContainerStyle={styles.container}&gt;<br>        {/* Using the reusable header component */}<br>        &lt;Header title=&quot;My Cart&quot; /&gt;</pre><pre>        {/* Mapping the products into the Cart component */}<br>        {cart?.items?.map((product) =&gt; (<br>          &lt;CartItem product={product} /&gt;<br>        ))}<br>      &lt;/ScrollView&gt;<br>      {/* Creating a seperate view to show the total amount and checkout button */}<br>      &lt;View&gt;<br>        &lt;View style={styles.row}&gt;<br>          &lt;Text style={styles.cartTotalText}&gt;Items&lt;/Text&gt;</pre><pre>          {/* Showing Cart Total */}<br>          &lt;Text<br>            style={[<br>              styles.cartTotalText,<br>              {<br>                color: &quot;#4C4C4C&quot;,<br>              },<br>            ]}<br>          &gt;<br>            {/* Dividing the total by 100 because Medusa doesn&#39;t store numbers in decimal */}<br>            ${cart?.total / 100}<br>          &lt;/Text&gt;<br>        &lt;/View&gt;<br>        &lt;View style={styles.row}&gt;<br>          {/* Showing the discount (if any) */}<br>          &lt;Text style={styles.cartTotalText}&gt;Discount&lt;/Text&gt;<br>          &lt;Text<br>            style={[<br>              styles.cartTotalText,<br>              {<br>                color: &quot;#4C4C4C&quot;,<br>              },<br>            ]}<br>          &gt;<br>            - ${cart?.discount_total / 100}<br>          &lt;/Text&gt;<br>        &lt;/View&gt;<br>        &lt;View style={[styles.row, styles.total]}&gt;<br>          &lt;Text style={styles.cartTotalText}&gt;Total&lt;/Text&gt;<br>          &lt;Text<br>            style={[<br>              styles.cartTotalText,<br>              {<br>                color: &quot;#4C4C4C&quot;,<br>              },<br>            ]}<br>          &gt;<br>            {/* Calculating the total */}$<br>            {cart?.total / 100 - cart?.discount_total / 100}<br>          &lt;/Text&gt;<br>        &lt;/View&gt;<br>        &lt;View&gt;<br>          {/* A button to navigate to checkout screen */}<br>          &lt;Button<br>            large={true}<br>            onPress={() =&gt; {<br>              Actions.checkout({<br>                cart,<br>              });<br>            }}<br>            title={cart?.items?.length &gt; 0 ? &quot;Checkout&quot; : &quot;Empty Cart&quot;}<br>          /&gt;<br>        &lt;/View&gt;<br>      &lt;/View&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>}</pre><pre>// Styles....<br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>  },<br>  row: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;space-between&quot;,<br>    width: widthToDp(90),<br>    marginTop: 10,<br>  },<br>  total: {<br>    borderTopWidth: 1,<br>    paddingTop: 10,<br>    borderTopColor: &quot;#E5E5E5&quot;,<br>    marginBottom: 10,<br>  },<br>  cartTotalText: {<br>    fontSize: widthToDp(4.5),<br>    color: &quot;#989899&quot;,<br>  },<br>});</pre><p>Next, you’ll add a basic and simple button component in the screens/Products.js in order to navigate to the cart screen.</p><p>Add the below code after the ScrollView component in the screens/Products.js screen:</p><pre>&lt;View style={styles.addToCart}&gt;<br>        &lt;Feather<br>          name=&quot;shopping-cart&quot;<br>          size={24}<br>          color=&quot;white&quot;<br>          onPress={() =&gt; Actions.cart()}<br>        /&gt;<br>      &lt;/View&gt;</pre><p>Make sure to also add the style object inside StyleSheet.create function:</p><pre>addToCart: {<br>    position: &quot;absolute&quot;,<br>    bottom: 30,<br>    right: 10,<br>    backgroundColor: &quot;#C37AFF&quot;,<br>    width: widthToDp(12),<br>    height: widthToDp(12),<br>    borderRadius: widthToDp(10),<br>    alignItems: &quot;center&quot;,<br>    padding: widthToDp(2),<br>    justifyContent: &quot;center&quot;,<br>  },</pre><p>You also need to import the feather icons from @expo/vector-icons at the top of the file:</p><pre>import { Feather } from &quot;@expo/vector-icons&quot;;</pre><h4>Test Cart Screen</h4><p>The cart screen is ready. Make sure that the Medusa server is running, then re-run your React Native app.</p><p>Try adding a few products into the cart, and then view the cart. Your cart screen should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*9Uj1bRtP9BpcXlnm.png" /></figure><h3>Checkout &amp; Payment</h3><p>Now that we have completed the cart flow, it is time for checkout flow.</p><h4>Configure the Stripe Plugin</h4><p>Navigate to the Medusa server directory and install the Stripe plugin by running the command below:</p><pre>npm install medusa-payment-stripe</pre><p>Add the following code at the end of the plugins array in the medusa-config.js.</p><pre>const plugins = [<br>  ...,<br>  {<br>    resolve: `medusa-payment-stripe`,<br>    options: {<br>      api_key: process.env.STRIPE_API_KEY,<br>    },<br>  },<br>];</pre><p>For this tutorial, I used Stripe to handle payments. Navigate to the Stripe dashboard and make sure to turn on the toggle button of <strong>Test Mode</strong> on the top right. Click the developers button beside the Test Mode. On the left, choose <strong>API key</strong> and you can find the <strong>Publishable key</strong> and <strong>Secret key</strong>. Copy the two keys, as you will need them later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*0-9X5CS1jo8YnGm6.png" /></figure><p>In the .env file, paste your secret key where is it written STRIPE_API_KEY.</p><h4>Enable Stripe as a Payment Provider</h4><p>Make sure that the Medusa server and admin panel is running. Now, open the Medusa admin panel and choose <strong>Settings</strong> from the Sidebar. Then, choose <strong>Regions</strong>.</p><p>Then, choose the regions you want to add Stripe as a payment provider. In the right-side settings, click on the three dots icon and choose “Edit Region Details”.</p><p>In the new window that opens, choose Stripe in the payment providers field. Once you’re done, click the <strong>save and close</strong> button.</p><h4>Checkout Screen</h4><p>Coming back to the React Native app, create a new file screens/Checkout.js and add a simple Text component to it:</p><pre>import { View, Text } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;</pre><pre>export default function Checkout() {<br>  return (<br>    &lt;View&gt;<br>      &lt;Text&gt;Checkout&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><p>Then, import the checkout screen at the top of <strong>App.js</strong>:</p><pre>import Checkout from &quot;./screens/Checkout&quot;;</pre><p>Add a new <strong>Scene</strong> component below the existing <strong>Scene</strong> components in the returned JSX:</p><pre>&lt;Scene key=&quot;checkout&quot; component={Checkout} hideNavBar /&gt;</pre><p>In the components folder, create a new file named ShippingAddress.js and you can add the following code to it:</p><pre>// Importing a few package and components<br>import { View, StyleSheet, Text, TextInput } from &quot;react-native&quot;;<br>import React, { useState } from &quot;react&quot;;<br>import { heightToDp } from &quot;rn-responsive-screen&quot;;</pre><pre>export default function ShippingAddress({ onChange }) {<br>  // Passing onChange as a prop</pre><pre>  // Declaring a few states to store the user&#39;s input<br>  const [firstName, setFirstName] = useState(&quot;&quot;);<br>  const [lastName, setLastName] = useState(&quot;&quot;);<br>  const [AddressLine1, setAddressLine1] = useState(&quot;&quot;);<br>  const [AddressLine2, setAddressLine2] = useState(&quot;&quot;);<br>  const [city, setCity] = useState(&quot;&quot;);<br>  const [country, setCountry] = useState(&quot;&quot;);<br>  const [province, setProvince] = useState(&quot;&quot;);<br>  const [postalCode, setPostalCode] = useState(&quot;&quot;);<br>  const [phone, setPhone] = useState(&quot;&quot;);<br>  const [company, setCompany] = useState(&quot;&quot;);<br>  const [email, setEmail] = useState(&quot;&quot;);</pre><pre>  // Function to handle the user&#39;s input<br>  const handleChange = () =&gt; {<br>    // Creating an object to store the user&#39;s input<br>    let address = {<br>      first_name: firstName,<br>      last_name: lastName,<br>            email,<br>      address_1: AddressLine1,<br>      address_2: AddressLine2,<br>      city,<br>      province,<br>      postal_code: postalCode,<br>      phone,<br>      company,<br>            country<br>    };<br>    // Calling the onChange function and passing the address object as an argument<br>    onChange(address);<br>  };</pre><pre>  return (<br>    // Creating a view to hold the user&#39;s input<br>    &lt;View style={styles.container}&gt;<br>      {/* Creating a text input for the user&#39;s first name */}<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          // Setting the user&#39;s input to the firstName state<br>          setFirstName(e);<br>          // Calling the handleChange function<br>          handleChange();<br>        }}<br>        placeholder=&quot;First Name&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setLastName(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Last Name&quot;<br>        style={styles.input}<br>      /&gt;<br>         &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setEmail(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Email&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setAddressLine1(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Address Line 1&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setAddressLine2(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Address Line 2&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setCity(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;City&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setCountry(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Country&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setProvince(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Province&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setPostalCode(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Postal Code&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setPhone(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Phone&quot;<br>        style={styles.input}<br>      /&gt;<br>      &lt;TextInput<br>        onChangeText={(e) =&gt; {<br>          setCompany(e);<br>          handleChange();<br>        }}<br>        placeholder=&quot;Company&quot;<br>        style={styles.input}<br>      /&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>// Creating a stylesheet to style the view<br>const styles = StyleSheet.create({<br>  container: {<br>    marginTop: heightToDp(2),<br>  },<br>  input: {<br>    borderWidth: 1,<br>    padding: 12,<br>    borderColor: &quot;#E5E5E5&quot;,<br>    borderRadius: 5,<br>    marginTop: 10.2,<br>  },<br>});</pre><p>In the above code, you imported a few components and created a function that handles the onChange event for the inputs. You have also created a few TextInputs for the shipping address.</p><p>Create a new file named RadioButton.js in the components folder and add the below code to it. It is a very simple component that will render radio buttons:</p><pre>import { View, Text, StyleSheet, TouchableOpacity } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;</pre><pre>const RadioButton = ({ onPress, selected, children }) =&gt; {<br>  return (<br>    &lt;View style={styles.radioButtonContainer}&gt;<br>      &lt;TouchableOpacity onPress={onPress} style={styles.radioButton}&gt;<br>        {selected ? &lt;View style={styles.radioButtonIcon} /&gt; : null}<br>      &lt;/TouchableOpacity&gt;<br>      &lt;TouchableOpacity onPress={onPress}&gt;<br>        &lt;Text style={styles.radioButtonText}&gt;{children}&lt;/Text&gt;<br>      &lt;/TouchableOpacity&gt;<br>    &lt;/View&gt;<br>  );<br>};<br>const styles = StyleSheet.create({<br>  radioButtonContainer: {<br>    flexDirection: &quot;row&quot;,<br>    alignItems: &quot;center&quot;,<br>    marginRight: 45,<br>  },<br>  radioButton: {<br>    height: 20,<br>    width: 20,<br>    backgroundColor: &quot;#F8F8F8&quot;,<br>    borderRadius: 10,<br>    borderWidth: 1,<br>    borderColor: &quot;#E6E6E6&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>  },<br>  radioButtonIcon: {<br>    height: 14,<br>    width: 14,<br>    borderRadius: 7,<br>    backgroundColor: &quot;#C37AFF&quot;,<br>  },<br>  radioButtonText: {<br>    fontSize: 16,<br>    marginLeft: 16,<br>  },<br>});<br>export default RadioButton;</pre><p>Create another file named stripe.js in the constants folder and add the below code. Make sure to update the YOUR_STRIPE_PUBLISHABLE_KEY with your publishable key:</p><pre>const publishable_key = &quot;YOUR_STRIPE_PUBLISHABLE_KEY&quot;;</pre><pre>export { publishable_key };</pre><p>Next, install the Stripe SDK for react native using the command below:</p><pre>npm install @stripe/stripe-react-native</pre><p>Now, update the checkout screen (screens/Checkout.js) by replacing the imports with the below components and dependencies:</p><pre>import { View, Text, StyleSheet } from &quot;react-native&quot;;<br>import React, { useEffect, useState } from &quot;react&quot;;<br>import Header from &quot;../components/Header&quot;;<br>import axios from &quot;axios&quot;;<br>import baseURL from &quot;../constants/url&quot;;<br>import { ScrollView } from &quot;react-native-gesture-handler&quot;;<br>import { SafeAreaView } from &quot;react-native-safe-area-context&quot;;<br>import { heightToDp, widthToDp } from &quot;rn-responsive-screen&quot;;<br>import Button from &quot;../components/Button&quot;;<br>import ShippingAddress from &quot;../components/ShippingAddress&quot;;<br>import Payment from &quot;../components/Payment&quot;;<br>import { publishable_key } from &quot;../constants/stripe&quot;;<br>import RadioButton from &quot;../components/RadioButton&quot;;<br>import { CardField, useStripe } from &quot;@stripe/stripe-react-native&quot;;<br>import AsyncStorage from &quot;@react-native-async-storage/async-storage&quot;;<br>import { StripeProvider } from &quot;@stripe/stripe-react-native&quot;;</pre><p>Next, create a few useStates that will be used to capture the input values in the Checkout component:</p><pre>const [paymentInfo, setPaymentInfo] = useState({});<br>const [shippingAddress, setShippingAddress] = useState({});<br>const [shippingOptions, setShippingOptions] = useState([]);<br>const [selectedShippingOption, setSelectedShippingOption] = useState(&quot;&quot;);<br>const [paymentSession, setPaymentSession] = useState({});</pre><pre>const { confirmPayment } = useStripe();</pre><p>Create two functions that will be used to capture the input values that we will declare later on.</p><pre>// const [selectedShippingOption, setSelectedShippingOption] = useState(&quot;&quot;);<br>// ......</pre><pre>  const handlePaymentInputChange = (card) =&gt; {<br>    setPaymentInfo(card.values);<br>  };</pre><pre>  const handleAddressInputChange = (address) =&gt; {<br>    setShippingAddress(address);<br>  };</pre><p>When the page opens and before the payment providers are displayed to the customer to choose from, you must initialize the <a href="https://docs.medusajs.com/advanced/backend/payment/overview#payment-session">payment sessions</a>. To do that, we create a function named InitializePaymentSessions and call it on useEffect function. Here is what the code should look like:</p><pre>const InitializePaymentSessions = async () =&gt; {<br>    // Getting cart id from async storage<br>    let cart_id = await AsyncStorage.getItem(&quot;cart_id&quot;);<br>    // Intializing payment session<br>    axios<br>      .post(`${baseURL}/store/carts/${cart_id}/payment-sessions`)<br>      .then(({ data }) =&gt; {<br>        axios<br>          .post(`${baseURL}/store/carts/${cart_id}/payment-session`, {<br>            provider_id: &quot;stripe&quot;,<br>          })<br>          .then(({ data }) =&gt; {<br>            setPaymentSession(data.cart.payment_session);<br>          });<br>      });<br>  };</pre><pre>  useEffect(() =&gt; {<br>    // Calling the function to fetch the payment options when the component mounts<br>    fetchPaymentOption();<br>  }, []);</pre><p>Next, create other functions to handle payment. Add the below functions the the Checkout.js :</p><pre>const handlePayment = async () =&gt; {</pre><pre>        // Getting client secret from the payment session state<br>    const clientSecret = paymentSession.data ? paymentSession.data.client_secret : paymentSession.client_secret</pre><pre>    const billingDetails = {<br>      email: shippingAddress.email,<br>      phone: shippingAddress.phone,<br>      addressCity: shippingAddress.city,<br>      addressCountry: shippingAddress.country,<br>      addressLine1: shippingAddress.address_1,<br>      addressLine2: shippingAddress.address_2,<br>      addressPostalCode: shippingAddress.postalCode,<br>    };<br>    const { error, paymentIntent } = await confirmPayment(clientSecret, {<br>      type: &quot;Card&quot;,<br>      billingDetails,<br>    });<br>        if (error) {<br>      alert(&quot;Payment failed&quot;, error);<br>    }<br>    if (paymentIntent) {<br>      alert(&quot;Payment successful&quot;);</pre><pre>// Calling the complete cart function to empty the cart and redirect to the home screen<br>    completeCart();<br>    }</pre><pre>  };</pre><pre>const completeCart = async () =&gt; {<br>    const cartId = await AsyncStorage.getItem(&quot;cart_id&quot;);</pre><pre>    // Sending a request to the server to empty the cart<br>    axios<br>      .post(`${baseURL}/store/carts/${cartId}/complete`)<br>      .then(async (res) =&gt; {<br>        // Removing the cart_id from the local storage<br>        await AsyncStorage.removeItem(&quot;cart_id&quot;);<br>        // Redirecting to the home screen<br>        Actions.push(&quot;products&quot;);<br>      });<br>  };</pre><pre>  // Calling the API when user presses the &quot;Place Order&quot; button<br>  const placeOrder = async () =&gt; {<br>    // Getting cart id from async storage<br>    let cart_id = await AsyncStorage.getItem(&quot;cart_id&quot;);<br>    // Post shipping address to server<br>    axios<br>      .post(`${baseURL}/store/carts/${cart_id}`, {<br>        shipping_address: shippingAddress,<br>      })<br>      .then(({ data }) =&gt; {<br>        // Post shipping method to server<br>        axios<br>          .post(`${baseURL}/store/carts/${cart_id}/shipping-methods`, {<br>            option_id: selectedShippingOption,<br>          })<br>          .then(({ data }) =&gt; {<br>            // Calling the handle Payment API<br>            handlePayment();<br>          });<br>      });<br>  };</pre><pre>  const fetchPaymentOption = async () =&gt; {<br>    // Getting cart id from async storage<br>    let cart_id = await AsyncStorage.getItem(&quot;cart_id&quot;);</pre><pre>    // Fetch shipping options from server<br>    axios<br>      .get(`${baseURL}/store/shipping-options/${cart_id}`)<br>      .then(({ data }) =&gt; {<br>        setShippingOptions(data.shipping_options);<br>        // Initializing payment session<br>        InitializePaymentSessions();<br>      });<br>  };</pre><p>These functions handle retrieving payment and shipping options from Medusa. It also handles processing the payment through Stripe, and then handles the checkout in Medusa.</p><p>You can also replace the return function with the below code:</p><pre>return (<br>&lt;StripeProvider publishableKey={publishable_key}&gt;<br>    &lt;SafeAreaView style={styles.container}&gt;<br>      &lt;ScrollView&gt;<br>        &lt;Header title=&quot;Checkout&quot; /&gt;<br>        &lt;View style={styles.address}&gt;<br>          &lt;Text style={styles.title}&gt;Shipping Address&lt;/Text&gt;<br>          &lt;ShippingAddress onChange={handleAddressInputChange} /&gt;<br>        &lt;/View&gt;</pre><pre>        &lt;View style={styles.payment}&gt;<br>          &lt;Text style={styles.title}&gt;Payment&lt;/Text&gt;<br>          &lt;CardField<br>            postalCodeEnabled={false}<br>            placeholders={{<br>              number: &quot;4242 4242 4242 4242&quot;,<br>            }}<br>            cardStyle={{<br>              backgroundColor: &quot;#FFFFFF&quot;,<br>              textColor: &quot;#000000&quot;,<br>            }}<br>            style={{<br>              width: &quot;100%&quot;,<br>              height: 50,<br>              marginVertical: 30,<br>            }}<br>            onCardChange={(cardDetails) =&gt; {<br>              handlePaymentInputChange(cardDetails);<br>            }}<br>            onFocus={(focusedField) =&gt; {<br>              console.log(&quot;focusField&quot;, focusedField);<br>            }}<br>          /&gt;<br>        &lt;/View&gt;<br>        &lt;View style={styles.shipping}&gt;<br>          &lt;Text style={styles.title}&gt;Shipping Options&lt;/Text&gt;<br>          {shippingOptions.map((option) =&gt; (<br>            &lt;View style={styles.shippingOption}&gt;<br>              &lt;RadioButton<br>                onPress={() =&gt; setSelectedShippingOption(option.id)}<br>                key={option.id}<br>                selected={selectedShippingOption === option.id}<br>                children={option.name}<br>              /&gt;<br>            &lt;/View&gt;<br>          ))}</pre><pre>          &lt;Button onPress={placeOrder} large title=&quot;Place Order&quot; /&gt;<br>        &lt;/View&gt;<br>      &lt;/ScrollView&gt;<br>    &lt;/SafeAreaView&gt;<br>&lt;/StripeProvider&gt;<br>  );</pre><p>Lastly, add the below style object at the end of the file:</p><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>  },<br>  address: {<br>    marginHorizontal: widthToDp(5),<br>  },<br>  payment: {<br>    marginHorizontal: widthToDp(5),<br>    marginTop: heightToDp(4),<br>  },<br>  shipping: {<br>    marginHorizontal: widthToDp(5),<br>  },<br>  title: {<br>    fontSize: widthToDp(4.5),<br>  },<br>  shippingOption: {<br>    marginTop: heightToDp(2),<br>  },<br>});</pre><p>And that’s it! You should now be able to make payments and purchase items from the store.</p><h4>Test Checkout Screen</h4><p>Now, try adding a few items to the cart and navigate to the checkout screen, you should be able to add an address and make payment. Here is what the checkout screen should look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*wI3Qp-7UizLAfvLY.png" /></figure><h3>What’s Next?</h3><p>This article is part 2 of <strong>Creating an ecommerce app using Medusa and React Native</strong>. You can also add more functionalities using Medusa:</p><ol><li>Add a search engine using <a href="https://docs.medusajs.com/add-plugins/meilisearch"><strong>MeiliSearch</strong></a>.</li><li>Check out the <a href="https://docs.medusajs.com/"><strong>documentation</strong></a> for what more you can do with Medusa.</li></ol><p>Should you have any issues or questions related to Medusa, feel free to reach out to the Medusa team via <a href="https://discord.gg/medusajs"><strong>Discord</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcf03ab79b4d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/medusa-commerce/create-a-react-native-ecommerce-app-with-medusa-part-2-adding-cart-and-checkout-fcf03ab79b4d">Create a React Native Ecommerce App with Medusa Part 2: Adding Cart and Checkout</a> was originally published in <a href="https://medium.com/medusa-commerce">Medusa</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use React Native and Medusa to Create an Ecommerce App]]></title>
            <link>https://medium.com/medusa-commerce/how-to-use-react-native-and-medusa-to-create-an-ecommerce-app-e722db48f75a?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e722db48f75a</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 13:00:41 GMT</pubDate>
            <atom:updated>2022-06-09T13:00:41.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qr15EZ7RZ2Go8rY4CrDu7Q.jpeg" /></figure><p><a href="https://reactnative.dev/">React Native</a> is a cross-platform mobile app framework that allows you to build native mobile applications for iOS and Android using JavaScript. It was developed by Meta Platforms, Inc. and it is currently among the most popular JavaScript frameworks with a huge active community behind it.</p><p><a href="https://github.com/medusajs/medusa">Medusa</a> is an open source headless commerce platform that allows you to create stores in a few minutes. It includes every feature a store needs such as order management, customers, payments, products, discounts, and a lot more.</p><p>In this tutorial, you are building a React Native ecommerce mobile application with Medusa. For this part, you are going to create two screens, one for all products and the other for the product info.</p><p>You can also find the source code of the application on the <a href="https://github.com/suhailkakar/react-native-medusajs"><strong>GitHub</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xTaPzi_qcaV63VRn.gif" /></figure><h3>Prerequisites</h3><p>Before you start with the tutorial make sure you have <a href="https://nodejs.org/en/">Node.js</a> v14 or greater installed on your machine.</p><h3>Set Up Medusa Server</h3><p>The first step is to setup the Medusa server, where the backend and APIs are handled.</p><p>You can install the Medusa CLI on your machine by running the following command:</p><pre>npm install -g @medusajs/medusa-cli</pre><p>Once the CLI is installed successfully, run the following command to create a Medusa project:</p><pre>medusa new my-medusa-store --seed</pre><p>The --seed option is used to add dummy data such as products and users to the store.</p><p>Change to the newly-created directory my-medusa-store and run the following command to start the medusa server:</p><pre>npm start</pre><p>It is recommended to add a storage plugin to be able to add products with images in Medusa. You can use <a href="https://docs.medusajs.com/add-plugins/minio"><strong>MinIO</strong></a>, <a href="https://docs.medusajs.com/add-plugins/s3/"><strong>AWS S3</strong></a>, or <a href="https://docs.medusajs.com/add-plugins/spaces/"><strong>Spaces</strong></a>.</p><h3>Set Up Medusa Admin</h3><p>Medusa has a very powerful admin dashboard where you can manage your products, payments, transaction, and more. This is very easy to setup however it is optional, so if you want you can skip this section.</p><p>In a separate directory, clone the Medusa Admin:</p><pre>git clone https://github.com/medusajs/admin medusa-admin</pre><p>Once it is cloned, you should see a new directory named medusa-admin. Navigate to the new directory and run the following command to install the dependencies of the project:</p><pre>npm install</pre><p>Finally, make sure that the Medusa server is still running and start the admin panel server by running the following command:</p><pre>npm run develop</pre><p>Now, open your browser and navigate to localhost:7000 and you should see the login page for admin panel. Login in to the admin with the below credentials.</p><ul><li>Email: <a href="/service/mailto:admin@medusa-test.com"><strong>admin@medusa-test.com</strong></a></li><li>Password: supersecret</li></ul><blockquote><em>The </em><em>--seed option you used earlier adds an admin user with the email and password</em></blockquote><p>Once you are logged in successfully, choose Products from sidebar and you should see the list of products in your store.</p><blockquote><em>If you are experiencing connection issues, it’s most likely because of CORS issues. Check </em><a href="https://docs.medusajs.com/troubleshooting/cors-issues"><em>here</em></a><em> how to fix it.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DogmZOBc6Fgz1E94.png" /></figure><p>You can also create a new product by clicking on the “New Product” button. Add information for your product such as a name, description, handle, variants, images, prices, and a lot more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f397-K4ohWHIwBPy.png" /></figure><h3>Set Up React Native Ecommerce Project</h3><p>Now that you have the store backend and admin panel ready it is time to start working on the react native ecommerce app.</p><p>In this tutorial, you are using Expo CLI to build the app. Run the following command to install the Expo CLI:</p><pre>npm install -g expo-cli</pre><p>Once the CLI is installed successfully, run the following command to create a new react native ecommerce project:</p><pre>expo init</pre><p>You will be promoted with some questions. You can follow the below code for the answers:</p><pre>What would you like to name your app? … medusa-store<br>Choose a template: › blank a minimal app as clean as an empty canvas<br>Downloaded template.</pre><pre>🧶 Using Yarn to install packages. Pass --npm to use npm instead.<br>Installed JavaScript dependencies.</pre><pre>✅ Your project is ready!</pre><pre>To run your project, navigate to the directory and run one of the following yarn commands.</pre><pre>- cd medusa-store<br>- yarn start # you can open iOS, Android, or web from here, or run them directly with the commands below.<br>- yarn android<br>- yarn ios<br>- yarn web</pre><p>Once the project is created successfully you should see a new directory named medusa-store. Navigate to the new directory and run the following command to install a few other dependencies:</p><pre>expo install react-native-screens react-native-router-flux react-native-reanimated rn-responsive-screen react-native-safe-area-context @expo/vector-icons react-native-gesture-handler axios</pre><ul><li>react-native-screens is used to expose native navigation container components to React Native.</li><li>react-native-router-flux provides API that helps users navigate between screens.</li><li>react-native-reanimated creates smooth animations and interactions that run on the UI thread.</li><li>rn-responsive-screen is a small package used for responsiveness in the app.</li><li>react-native-safe-area-context is a flexible way to handle safe areas.</li><li>react-native-gesture-handler provides native-driven gesture management APIs for building the best possible touch-based experiences.</li><li>axios is a promise-based HTTP Client to easily send requests to REST APIs and perform CRUD operations.</li><li>@expo/vector-icons includes popular icons sets which you can use in the app.</li></ul><p>After the packages are installed successfully, start the development server by running the following:</p><pre>expo start</pre><p>You can either scan the QR code using your device or run the app on an Android/iOS simulator. Once the app is shown on your mobile, you should see a similar screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*BGulqEzF6ZjOE5pH.png" /></figure><p>This is a basic react native code in the App.js file.</p><h3>Set Up Routes</h3><p>In this section, you’ll set up different routes in your app.</p><p>Before setting up the routes, you have to create a few screens. Create a new folder named screensand inside it create a new file named Products.js.</p><p>Inside Products.js insert the following code:</p><pre>import { StyleSheet, Text, View } from &quot;react-native&quot;;</pre><pre>export default function Products() {<br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;Text&gt;Product Screen!&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>  },<br>});</pre><p>For now it contains a very simple Text component.</p><p>Now that you have a screen setup, you can continue to add routes to the project. Replace the code inside of the App.js with the following:</p><pre>import { Router, Scene, Stack } from &quot;react-native-router-flux&quot;;<br>import Products from &quot;./screens/Products&quot;;</pre><pre>export default function App() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Stack key=&quot;root&quot;&gt;<br>        &lt;Scene key=&quot;products&quot; component={Products} hideNavBar /&gt;<br>      &lt;/Stack&gt;<br>    &lt;/Router&gt;<br>  );<br>}</pre><p>In the above code, you are using react-native-router-flux to create the navigation. Router is used as a parent component and each Scene represents one screen. For now you have just one screen.</p><p>Save the file and you might see an error similar to this.</p><pre>Error: Requiring module &quot;node_modules/react-native-reanimated/src/Animated.js&quot;, which threw an exception: Error: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated&#39;s babel plugin?</pre><p>It is because that react-native-router-flux uses react-native-reanimated and in order to make it work you need to add it to babel.config.js. Open the babel file from your directory and add the below line after presents:</p><pre>plugins: [&quot;react-native-reanimated/plugin&quot;],1</pre><p>Save the file and restart the server with the following command:</p><pre>expo start -c</pre><p>The option -c clears the cache before running the server.</p><blockquote><em>If you see the error “Invariant Violation: Tried to register two views with the same name RNGestureHandlerButton”, delete the </em><em>node_modules directory and use </em><a href="https://yarnpkg.com/"><em>Yarn</em></a><em> to re-install the dependencies.</em></blockquote><h3>Products List Screen</h3><p>Create a new folder in the root directory named components. In the components folder create 3 files. Button.js, ProductCard.js, and Header.js.</p><p>In the Button.js file insert the following code to create a basic button component:</p><pre>import { View, Text, StyleSheet } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;<br>import { widthToDp } from &quot;rn-responsive-screen&quot;;</pre><pre>export default function Button({ title, onPress, style, textSize }) {<br>  return (<br>    &lt;View style={[styles.container, style]}&gt;<br>      &lt;Text<br>        style={[styles.text, { fontSize: textSize ? textSize : widthToDp(3.5) }, ]}<br>        onPress={onPress}<br>      &gt;<br>        {title}<br>      &lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    backgroundColor: &quot;#C37AFF&quot;,<br>    padding: 5,<br>    width: widthToDp(20),<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>    borderRadius: 59,<br>  },<br>  text: {<br>    color: &quot;#fff&quot;,<br>    fontWeight: &quot;bold&quot;,<br>  },<br>});</pre><p>Similarly in the Header.js insert the following code to create a simple header component:</p><pre>import { View, Image, StyleSheet, Text } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;</pre><pre>export default function Header({ title }) {<br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;Image<br>        source={{<br>          uri: &quot;https://user-images.githubusercontent.com/7554214/153162406-bf8fd16f-aa98-4604-b87b-e13ab4baf604.png&quot;,<br>        }}<br>        style={styles.logo}<br>      /&gt;<br>      &lt;Text style={styles.title}&gt;{title}&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}<br>const styles = StyleSheet.create({<br>  container: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;space-between&quot;,<br>    alignItems: &quot;center&quot;,<br>    marginBottom: 10,<br>  },<br>  title: {<br>    fontSize: 20,<br>    fontWeight: &quot;500&quot;,<br>  },<br>  logo: {<br>    width: 50,<br>    height: 50,<br>  },<br>});</pre><p>The last one is ProductCard.js. It is the main component in which you render the product data:</p><pre>import { View, Text, Image, StyleSheet } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;<br>import { widthToDp, heightToDp } from &quot;rn-responsive-screen&quot;;<br>import Button from &quot;./Button&quot;;</pre><pre>export default function ProductCard({ key, product }) {<br>  return (<br>    &lt;View style={styles.container} key={key}&gt;<br>      &lt;Image<br>        source={{<br>          uri: product.thumbnail,<br>        }}<br>        style={styles.image}<br>      /&gt;<br>      &lt;Text style={styles.title}&gt;{product.title}&lt;/Text&gt;<br>      &lt;Text style={styles.category}&gt;{product.handle}&lt;/Text&gt;<br>      &lt;View style={styles.priceContainer}&gt;<br>        &lt;Text style={styles.price}&gt;<br>          ${product.variants[0].prices[1].amount / 100}<br>        &lt;/Text&gt;</pre><pre>        &lt;Button<br>          title=&quot;BUY&quot;<br>        /&gt;<br>      &lt;/View&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    shadowColor: &quot;#000&quot;,<br>    borderRadius: 10,<br>    marginBottom: heightToDp(4),<br>    shadowOffset: {<br>      width: 2,<br>      height: 5,<br>    },<br>    shadowOpacity: 0.25,<br>    shadowRadius: 6.84,<br>    elevation: 5,<br>    padding: 10,<br>    width: widthToDp(42),<br>    backgroundColor: &quot;#fff&quot;,<br>  },<br>  image: {<br>    height: heightToDp(40),<br>    borderRadius: 7,<br>    marginBottom: heightToDp(2),<br>  },<br>  title: {<br>    fontSize: widthToDp(3.7),<br>    fontWeight: &quot;bold&quot;,<br>  },<br>  priceContainer: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;space-between&quot;,<br>    alignItems: &quot;center&quot;,<br>    marginTop: heightToDp(3),<br>  },<br>  category: {<br>    fontSize: widthToDp(3.4),<br>    color: &quot;#828282&quot;,<br>    marginTop: 3,<br>  },<br>  price: {<br>    fontSize: widthToDp(4),<br>    fontWeight: &quot;bold&quot;,<br>  },<br>});</pre><blockquote><em>In the above code, the product price is divided by 100 because in Medusa the prices are hosted on the server without decimals.</em></blockquote><p>Create a new folder named constants and inside it create a new file named url.js with the following content:</p><pre>const baseURL = &quot;http://127.0.0.1:9000&quot;;</pre><pre>export default baseURL;</pre><p>In the above code, you define your Medusa server’s base URL. To be able to connect from your device to the local server, you must change the value of baseURL to your machine’s IP address. You can refer to <a href="https://www.whatismybrowser.com/detect/what-is-my-local-ip-address">this guide</a> to learn how to find your IP address.</p><p>That’s it for the components. Now replace the code in the Products.js with the following:</p><pre>import { ScrollView, StyleSheet,TouchableOpacity, View } from &quot;react-native&quot;;<br>import React, { useEffect, useState } from &quot;react&quot;;<br>import ProductCard from &quot;../components/ProductCard&quot;;<br>import { widthToDp } from &quot;rn-responsive-screen&quot;;<br>import axios from &quot;axios&quot;;<br>import Header from &quot;../components/Header&quot;;<br>import { Actions } from &quot;react-native-router-flux&quot;;<br>import baseURL from &quot;../constants/url&quot;;</pre><pre>export default function Products() {<br>  const [products, setProducts] = useState([]);</pre><pre>  function fetchProducts() {<br>		axios.get(`${baseURL}/store/products`).then((res) =&gt; {<br>      setProducts(res.data.products);<br>    }); <br> }</pre><pre>  useEffect(() =&gt; {<br>    fetchProducts();<br>  }, []);</pre><pre>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;Header title=&quot;Medusa&#39;s Store&quot; /&gt;<br>      &lt;ScrollView&gt;<br>        &lt;View style={styles.products}&gt;<br>          {products.map((product) =&gt; (<br>            &lt;ProductCard key={product.id} product={product} /&gt;<br>          ))}<br>        &lt;/View&gt;<br>      &lt;/ScrollView&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    paddingTop: 50,<br>    backgroundColor: &quot;#fff&quot;,<br>    alignItems: &quot;center&quot;,<br>    justifyContent: &quot;center&quot;,<br>  },<br>  products: {<br>    flex: 1,<br>    flexDirection: &quot;row&quot;,<br>    flexWrap: &quot;wrap&quot;,<br>    width: widthToDp(100),<br>    paddingHorizontal: widthToDp(4),<br>    justifyContent: &quot;space-between&quot;,<br>  },<br>});</pre><p>In the code above, you call fetchProducts when the screen loads using useEffect. In the fetchProducts function, you use axios to fetch the <a href="https://docs.medusajs.com/api/store/product/list-products">products from the Medusa server</a> and save it in the state.</p><p>Once you fetch the products, you render them using the ProductCard component.</p><p>Save the file and make sure that Expo and the Medusa server are running. Then, open the app on your device and you should see on the home screen the products from your Medusa server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*cZAj8l8vfmlxVbTy.png" /></figure><h3>Product Info Screen</h3><p>In this section, you’ll create the Product Info screen where the user can see more details about the product.</p><p>In the screens directory, create a new file named ProductInfo.js and for now you can use it to render a simple Text component:</p><pre>import { View, Text } from &quot;react-native&quot;;<br>import React from &quot;react&quot;;</pre><pre>export default function ProductInfo() {<br>  return (<br>    &lt;View&gt;<br>      &lt;Text&gt;Product Info Screen&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><p>Then, add the import ProductInfo at the top of App.js:</p><pre>import ProductInfo from &quot;./screens/ProductInfo&quot;;</pre><p>And add a new Scene component below the existing Scene component in the returned JSX:</p><pre>&lt;Scene key=&quot;ProductInfo&quot; component={ProductInfo} hideNavBar /&gt;</pre><p>In the components directory, create a new directory named ProductInfo and create inside it Image.js with the following content:</p><pre>import { View, TouchableOpacity, Image, StyleSheet } from &quot;react-native&quot;;<br>import React, { useEffect, useState } from &quot;react&quot;;<br>import { widthToDp } from &quot;rn-responsive-screen&quot;;</pre><pre>export default function Images({ images }) {<br>  const [activeImage, setActiveImage] = useState(null);</pre><pre>  useEffect(() =&gt; {<br>    setActiveImage(images[0].url);<br>  }, []);</pre><pre>  return (<br>    &lt;View style={styles.imageContainer}&gt;<br>      &lt;Image source={{ uri: activeImage }} style={styles.image} /&gt;<br>      &lt;View style={styles.previewContainer}&gt;<br>        {images.map((image, index) =&gt; (<br>          &lt;TouchableOpacity<br>            key={index}<br>            onPress={() =&gt; {<br>              setActiveImage(image.url);<br>            }}<br>          &gt;<br>            &lt;Image<br>              source={{ uri: image.url }}<br>              style={[<br>                styles.imagePreview,<br>                {<br>                  borderWidth: activeImage === image.url ? 3 : 0,<br>                },<br>              ]}<br>            /&gt;<br>          &lt;/TouchableOpacity&gt;<br>        ))}<br>      &lt;/View&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  image: {<br>    width: widthToDp(100),<br>    height: widthToDp(100),<br>  },<br>  previewContainer: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;center&quot;,<br>    alignItems: &quot;center&quot;,<br>    marginTop: widthToDp(-10),<br>  },<br>  imageContainer: {<br>    backgroundColor: &quot;#F7F6FB&quot;,<br>    paddingBottom: widthToDp(10),<br>  },<br>  imagePreview: {<br>    width: widthToDp(15),<br>    marginRight: widthToDp(5),<br>    borderColor: &quot;#C37AFF&quot;,<br>    borderRadius: 10,<br>    height: widthToDp(15),<br>  },<br>});</pre><p>In the above component you display a main big image and below it the rest of the product images as thumbnails. When the user press on one of the thumbnail images it is set as the active image and displayed as the main image.</p><p>In the Products.js file, replace the map function in the returned JSX with the following:</p><pre>{products.map((product) =&gt; (<br>    &lt;TouchableOpacity key={product.id} onPress={() =&gt; Actions.ProductInfo({ productId: product.id })}&gt;<br>      &lt;ProductCard product={product} /&gt;<br>    &lt;/TouchableOpacity&gt;<br>  ))<br>}</pre><p>You add a TouchableOpacity that navigates the user to the product info screen when they click on a product.</p><blockquote><em>Using </em><em>react-router-flux you pass the product ID from the home screen to the product info screen.</em></blockquote><p>Then, replace the code in ProductInfo.js with the following:</p><pre>import { View, Text, ScrollView,TouchableOpacity, StyleSheet } from &quot;react-native&quot;;<br>import React, { useState, useEffect } from &quot;react&quot;;<br>import axios from &quot;axios&quot;;<br>import { SafeAreaView } from &quot;react-native-safe-area-context&quot;;<br>import Images from &quot;../components/ProductInfo/Image&quot;;<br>import baseURL from &quot;../constants/url&quot;;<br>import { Actions } from &quot;react-native-router-flux&quot;;<br>import { Ionicons } from &quot;@expo/vector-icons&quot;;</pre><pre>export default function ProductInfo({ productId }) {<br>  const [productInfo, setproductInfo] = useState(null);</pre><pre>	useEffect(() =&gt; {<br>    axios.get(`${baseURL}/store/products/${productId}`).then((res) =&gt; {<br>      setproductInfo(res.data.product);<br>    });<br>  }, []);</pre><pre>  return (<br>    &lt;SafeAreaView style={styles.container}&gt;<br>			&lt;TouchableOpacity onPress={() =&gt; Actions.pop()}&gt;<br>        &lt;Ionicons<br>          style={styles.icon}<br>          name=&quot;arrow-back-outline&quot;<br>          size={24}<br>          color=&quot;black&quot;<br>        /&gt;<br>      &lt;/TouchableOpacity&gt;<br>      &lt;ScrollView&gt;<br>        {productInfo &amp;&amp; (<br>          &lt;View&gt;<br>            &lt;Images images={productInfo.images} /&gt;<br>          &lt;/View&gt;<br>        )}<br>      &lt;/ScrollView&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>container: {<br>    flex: 1,<br>    backgroundColor: &quot;#fff&quot;,<br>    justifyContent: &quot;center&quot;,<br>  },<br>  icon: {<br>    marginLeft: 10,<br>  },<br>});</pre><p>To briefly explain the code snippet:</p><ul><li>First you import all necessary components.</li><li>Then you fetch the product data in useEffect function and save it in the state.</li><li>Finally, you display the images using the Images component.</li></ul><p>Open the app now and click on any product on the home screen. A new screen will open showing the product’s images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*Czu8JaWf0DLu4hhI.png" /></figure><p>Now, you’ll display the product’s information.</p><p>In the components folder, inside the ProductInfo directory create a new file named MetaInfo.js with the following content:</p><pre>import { View, Text, StyleSheet } from &quot;react-native&quot;;<br>import React, { useState } from &quot;react&quot;;<br>import { height, heightToDp } from &quot;rn-responsive-screen&quot;;</pre><pre>export default function MetaInfo({ product }) {<br>  const [activeSize, setActiveSize] = useState(0);<br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;View style={styles.row}&gt;<br>        &lt;Text style={styles.title}&gt;{product.title}&lt;/Text&gt;<br>        &lt;View&gt;<br>          &lt;Text style={styles.price}&gt;<br>            ${product.variants[0].prices[1].amount / 100}<br>          &lt;/Text&gt;<br>          &lt;Text style={styles.star}&gt;⭐⭐⭐&lt;/Text&gt;<br>        &lt;/View&gt;<br>      &lt;/View&gt;<br>      &lt;Text style={styles.heading}&gt;Available Sizes&lt;/Text&gt;<br>      &lt;View style={styles.row}&gt;<br>        {product.options[0].values.map((size, index) =&gt; (<br>          &lt;Text<br>            onPress={() =&gt; {<br>              setActiveSize(index);<br>            }}<br>            style={[<br>              styles.sizeTag,<br>              {<br>                borderWidth: activeSize === index ? 3 : 0,<br>              },<br>            ]}<br>          &gt;<br>            {size.value}<br>          &lt;/Text&gt;<br>        ))}<br>      &lt;/View&gt;<br>      &lt;Text style={styles.heading}&gt;Description&lt;/Text&gt;<br>      &lt;Text style={styles.description}&gt;{product.description}&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><pre>const styles = StyleSheet.create({<br>  container: {<br>    marginTop: heightToDp(-5),<br>    backgroundColor: &quot;#fff&quot;,<br>    borderTopLeftRadius: 20,<br>    borderTopRightRadius: 20,<br>    height: heightToDp(50),<br>    padding: heightToDp(5),<br>  },<br>  title: {<br>    fontSize: heightToDp(6),<br>    fontWeight: &quot;bold&quot;,<br>  },<br>  row: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;space-between&quot;,<br>    alignItems: &quot;center&quot;,<br>  },<br>  price: {<br>    fontSize: heightToDp(5),<br>    fontWeight: &quot;bold&quot;,<br>    color: &quot;#C37AFF&quot;,<br>  },<br>  heading: {<br>    fontSize: heightToDp(5),<br>    marginTop: heightToDp(3),<br>  },<br>  star: {<br>    fontSize: heightToDp(3),<br>    marginTop: heightToDp(1),<br>  },<br>  sizeTag: {<br>    borderColor: &quot;#C37AFF&quot;,<br>    backgroundColor: &quot;#F7F6FB&quot;,<br>    color: &quot;#000&quot;,<br>    paddingHorizontal: heightToDp(7),<br>    paddingVertical: heightToDp(2),<br>    borderRadius: heightToDp(2),<br>    marginTop: heightToDp(2),<br>    overflow: &quot;hidden&quot;,<br>    fontSize: heightToDp(4),<br>    marginBottom: heightToDp(2),<br>  },<br>  description: {<br>    fontSize: heightToDp(4),<br>    color: &quot;#aaa&quot;,<br>    marginTop: heightToDp(2),<br>  },<br>});</pre><p>In the above component, you render the product title, price, description and variants.</p><p>For the product variant, you map all the variants and when a user press on one of them, you set that variant as active.</p><p>Save the MetaInfo.js file and import it at the top of screens/ProductInfo.js:</p><pre>import MetaInfo from &quot;../components/ProductInfo/MetaInfo&quot;;</pre><p>Then, in the returned JSX add the MetaInfo component below the Images component:</p><pre>&lt;MetaInfo product={productInfo} /&gt;</pre><p>Save the changes and check the app now. The product info screen now shows details about the product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*tRo47aXisWehhy2U.png" /></figure><h3>What’s Next?</h3><p>This article gives you the basis to creating a Medusa and React Native ecommerce app. Here are some more functionalities you can add using Medusa:</p><ol><li><a href="https://docs.medusajs.com/api/store/cart/add-a-shipping-method">Add a cart and allow adding products to cart.</a></li><li>Add a payment provider using <a href="https://docs.medusajs.com/guides/checkouts/#selecting-payment-provider">Stripe</a>.</li><li>Add a search engine using <a href="https://docs.medusajs.com/add-plugins/meilisearch">MeiliSearch</a>.</li><li>Check out the <a href="https://docs.medusajs.com/">documentation</a> for what more you can do with Medusa.</li></ol><blockquote><em>Should you have any issues or questions related to Medusa, then feel free to reach out to the Medusa team via </em><a href="https://discord.gg/medusajs"><em>Discord</em></a><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e722db48f75a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/medusa-commerce/how-to-use-react-native-and-medusa-to-create-an-ecommerce-app-e722db48f75a">How to Use React Native and Medusa to Create an Ecommerce App</a> was originally published in <a href="https://medium.com/medusa-commerce">Medusa</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Solve Captcha in JavaScript Using 2Captcha]]></title>
            <link>https://suhailkakar.medium.com/how-to-solve-captcha-in-javascript-using-2captcha-66d1470f0d2a?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/66d1470f0d2a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[captcha]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Thu, 11 Nov 2021 08:56:01 GMT</pubDate>
            <atom:updated>2021-11-11T08:56:01.015Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7lThHOfwr3Lxc78K" /><figcaption>Photo by <a href="https://unsplash.com/@possessedphotography?utm_source=medium&amp;utm_medium=referral">Possessed Photography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You may already solve many captchas while submitting a form or signing up for a website. The basic Captcha goal is to check whether the user is a human or a bot. Captcha stands for <strong>Completely Automated Public Turing test to tell Computers and Humans Apart</strong>. Captchas are used to stop spamming blogs, accessing bots, and making a website more secure.</p><p>Sometimes it is easy to solve the captcha, however, some of them are just a headache to the users, It might take minutes to think whether the letter is in Upper Case or Lower Case. Therefore, nowadays users prefer to use captcha-solving software.</p><p>2Captcha is among those services, which help us solve captchas, within seconds. It is a Captcha recognition service for solving challenge-response tests called Captcha to determine whether the user is a human or not.</p><h3>What is 2Captcha</h3><p>2Captcha is a Captcha recognition service solving captchas in real-time. It also provides image recognition services powered by human intelligence. 2captcha can recognize different types of captcha and Its API is available for most programming languages. As the 2captcha uses the human-based method to solve captchas, It provides the opportunity to earn by solving the captchas.</p><h3>Advantages of 2captcha</h3><ul><li>Provide a high level of accuracy</li><li>human-based method to solve captchas</li><li>Average speed of solving a captcha is less than 12 sec</li><li>API available for most popular programming languages</li><li>Solve all kinds of captchas</li><li>Reliable reCAPTCHA solving service</li><li>Provide 100% recognition service</li></ul><h3>How to solve Captcha in JavaScript using 2Captcha</h3><p>Here I use the Discord registration form which has a captcha to be solved using javascript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*t8-QHgtyFWszMepX.png" /></figure><p>When you fill this form and click continue, you will see the below captcha.</p><p>In order to solve the captcha using javascript, we can use two libraries called <strong>axios</strong> and <strong>2captcha</strong>. The axios is used to handle all the API calls and 2captcha is used to solve the captcha. install the bellow packages after creating your file.</p><pre>npm install axios</pre><pre>npm install 2captcha</pre><ul><li>import these libraries to your file</li></ul><pre>const axios = require(&quot;axios&quot;);</pre><pre>const Captcha = require(&quot;2captcha&quot;);</pre><ul><li>Initialize the captcha with your API key, You can get your API key when you Sign up. The API_KEY is available on your dashboard at the Account setting</li></ul><pre>const solver = new Captcha.Solver(&quot;API_KEY&quot;);</pre><ul><li>define an async function, here we call it register. we can solve the captcha using the solver which we already initialized and captcha is the type of captcha that we have on Discord website. It requires two parameters, the Site key and the website URL. The</li></ul><pre>const register = async () =&gt; {<br>  console.log(&quot;solving...&quot;);<br>  const { data } = await solver.hcaptcha(<br>    &quot;f5561ba9-8f1e-40ca-9b5b-a0b3f719ef34&quot;,<br>    &quot;https://discord.com/register&quot;<br>  );</pre><p>You can get the site key when you press ctrl+shift+i and the site key will be on the HTML section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*pN3d30sWvUQTOo7k.png" /></figure><p>Use try-catch, as it may have any error and inside the try, we can ake the Axios call. Here the method is Post and you should specify the request URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*hcY95_aUoHjA1m4l.png" /></figure><p>The second parameter is the data that you post to the particular website.<br>The captcha key value will be the data we specify earlier. I got the data when I filled the discord form and it sent a request.</p><p>The captcha_key value is null because I didn’t solve the captcha yet, therefore in try-catch, the captcha value will be data.</p><pre>try {<br>    let result = await axios.post(&quot;https://discord.com/api/v9/auth/register&quot;, {<br>        captcha_key: data,<br>        consent: true,<br>        date_of_birth: &quot;1985-05-03&quot;,<br>        email: &quot;email@gmail.com&quot;,<br>        fingerprint: &quot;907561243135578163.UkNRz9ryt1bnxZbz7hqbnZdEgLc&quot;,<br>        gift_code_sku_id: null,<br>        invite: null,<br>        password: &quot;mySecretPassword@23&quot;,<br>        username: &quot;suhailkakar&quot;,</pre><pre>    });<br>    console.log(result.data);<br>} catch (e) {<br>    console.log(e);<br>}<br>};</pre><p>Here is all the code that we explained, call your function at the end of the program.</p><pre>const axios = require(&quot;axios&quot;);<br>const Captcha = require(&quot;2captcha&quot;);</pre><pre>const solver = new Captcha.Solver(&quot;e822d75f8b3ad5187e5bcfb1c0665ce9&quot;);<br>const register = async () =&gt; {<br>    const {<br>        data<br>    } = await solver.hcaptcha(<br>        &quot;f5561ba9-8f1e-40ca-9b5b-a0b3f719ef34&quot;,<br>        &quot;https://discord.com/register&quot;<br>    );</pre><pre>    try {<br>        let result = await axios.post(&quot;https://discord.com/api/v9/auth/register&quot;, {<br>            captcha_key: data,<br>            consent: true,<br>            date_of_birth: &quot;1985-05-03&quot;,<br>            email: &quot;fdffnjnJNjsnxjn@gmail.com&quot;,<br>            fingerprint: &quot;907561243135578163.UkNRz9ryt1bnxZbz7hqbnZdEgLc&quot;,<br>            gift_code_sku_id: null,<br>            invite: null,<br>            password: &quot;bjhdjfhfbjfb&quot;,<br>            username: &quot;ffdvvxjvvnfj&quot;,<br>        });<br>        console.log(result.data);<br>    } catch (e) {<br>        console.log(e);<br>    }<br>};<br>register();</pre><ul><li>Run node your_file_name, in our case node app.js on the terminal.</li></ul><p>It will take a bit of time and then you will receive a token. We will use the below function to pass the token and</p><pre>function login(token) {<br>    setInterval(() =&gt; {<br>        document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `&quot;${token}&quot;`<br>    }, 50);<br>    setTimeout(() =&gt; {<br>        location.reload();<br>    }, 2500);<br>}</pre><p>Paste the above code in your console and it will log in directly to the website without solving the captcha.</p><h3>Conclusion</h3><p>That is it for this article. I hope you found this article useful, if you need any help please let me know in the comment section.</p><p>Would you like to buy me a coffee, You can do it <a href="https://www.buymeacoffee.com/suhailkakar">here</a>.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a>.</p><p>👋 Thanks for reading, See you next time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66d1470f0d2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Are DApps: A Complete Guide To Decentralized Applications]]></title>
            <link>https://suhailkakar.medium.com/what-are-dapps-a-complete-guide-to-decentralized-applications-19d6040f120a?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/19d6040f120a</guid>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Mon, 08 Nov 2021 10:26:10 GMT</pubDate>
            <atom:updated>2021-11-08T10:26:10.622Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rZEwN_iDg6OaXwga" /><figcaption>Photo by <a href="https://unsplash.com/@nasa?utm_source=medium&amp;utm_medium=referral">NASA</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A decentralized app (dApp) is a digital application or a program that resides and executes on a blockchain or peer-to-peer network of computers rather than a single computer and is independent of anyone’s authority’s control.</p><p>DApps is short for Decentralized applications which means it is not controlled by a single organization and they are playing a vital role in the world of blockchain. These decentralized applications operate on a blockchain network in a public, open-source, and decentralized environment that is free of central control and influence.</p><p>Here is a great example of dApps by <a href="https://hashnode.com/@catmcgee">Cat McGee</a>, which she mentioned in a <a href="https://twitter.com/hashnode/status/1455453722948034563">Twitter Space</a> organized by Hashnode.</p><p>You can create a Twitter-like dApp and deploy it on a blockchain, allowing any user to post tweets. Once they’ve been uploaded no one, even you (app maker) can delete those tweets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z0NjzlNng_cI0L-d" /></figure><p>Some dApps features are</p><ul><li>It is open-source which means that its source code is available for common users.</li><li>When miners successfully contribute to the ecosystem, they are rewarded with tokens.</li><li>It is decentralized and adopts blockchain technology.</li></ul><p>Now that you have good knowledge about dApps, let’s learn what are their benefits.</p><h3>Benefits of dApps</h3><p>DApps have many benefits, however, in this article, I have mentioned only a few of them such as</p><h3>No downtime</h3><p>There will be no downtime or restrictions as it doesn’t rely on a single point of failure like a hosting server instead it runs on a peer-to-peer network of computers.</p><h3>Transparency</h3><p>Data from decentralized applications are stored on a public ledger, which keeps track of everything in a safe and transparent manner that ensures no one can tamper with it.</p><h3>Open-source</h3><p>The code of open-source dApps is available for review. Because more input can be offered, and the entire ecosystem can be more adaptable, progress faster, and evolve more safely.</p><p>And yes, we all know, everything has both benefits and drawbacks, so here are a few Drawbacks of dApps</p><h3>Drawbacks of dApps</h3><h3>UX/User experience</h3><p>It may be more difficult to create user-friendly experiences since setting up the tool stack required to communicate with the blockchain in a properly safe manner may be too difficult for the average end-user.</p><h3>Maintenance</h3><p>Because every peer in the network must update their node software, running in a complicated environment dispersed amongst peers makes maintenance, debugging, and updates more difficult.</p><h3>Fewer Third-Party DApps</h3><p>Sometimes we have to rely on third-party APIs to collect certain third-party information under the present centralized app structure. We don’t have this advantage with DApps because there isn’t yet a substantial third-party DApps ecosystem in place.</p><p><em>Because DApps cannot access APIs through a centralized application, they must engage with other DApps for their API needs, which is also a drawback.</em></p><h3>Conclusion</h3><p>That is it for this article. I hope you found this article useful, if you need any help please let me know in the comment section.</p><p>Would you like to buy me a coffee, You can do it <a href="https://www.buymeacoffee.com/suhailkakar">here</a>.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a>.</p><p>👋 Thanks for reading, See you next time</p><p><em>Originally published at </em><a href="https://blog.suhailkakar.com/what-are-dapps-a-complete-guide-to-decentralized-applications">blog.suhailkakar.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19d6040f120a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I use ClickUp to efficiently organize my day]]></title>
            <link>https://suhailkakar.medium.com/how-i-use-clickup-to-efficiently-organize-my-day-daa5807fb36d?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/daa5807fb36d</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[clickup]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Tue, 12 Oct 2021 06:08:30 GMT</pubDate>
            <atom:updated>2021-10-12T06:08:30.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o4UqTPcEWfEaAviY" /><figcaption>Photo by <a href="https://unsplash.com/@joszczepanska?utm_source=medium&amp;utm_medium=referral">Jo Szczepanska</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We all deal with projects, whether we’re project managers, members of project teams, or regular developers. If you work in the corporate world, you know how easily large projects may get disorganized, but not anymore, in this article, I am going to describe how I use ClickUp to efficiently organize my day.</p><h3>What is ClickUp</h3><p>ClickUp is a powerful project management tool for both teams and individuals. It combines important business applications and centralizes company information into a single online solution.</p><h3>How I use ClickUp</h3><p>There are numerous reasons why I use ClickUp in my everyday life; nevertheless, I will highlight a few of them in this article.</p><h3>Spaces</h3><p>Spaces break down your workspaces into different departments, teams, groups, high-level initiatives, or really anything you want to group at a high level.</p><p>For example, if you create a Workspace to manage your Social Media presence, you can use Spaces to organize your Facebook post, Twitter tweets, Linkedin job posting and etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zdZqfIE3WuL2MHno" /></figure><p>The second level of the ClickUp hierarchy is Spaces, which allows you to personalize anything. Usually, this is the ClickUp hierarchy</p><pre>ClickUp ✨<br>    └── Workspaces<br>        └── Space<br>            └── Folder<br>                └── List<br>                    └── Tasks</pre><h3>Tasks</h3><p>This is the feature that I use to organize my blog article and Twitter threads/tweets. Each task can have a status, priority, and lots of other stuff. You can also add a subtask to each task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9dXOM9CsNM7p2T0N" /></figure><h3>Wikis</h3><p>This is the place, where I draft my article and write my tweets/threads. It has a WYSIWYG — Markdown editor. I use this tool daily in order to draft my article and after some review, I will publish it on Hashnode.</p><p>You can also publish your wiki/doc directly from ClickUp and it will give you a shareable link. Pretty cool haaa…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z5hkXo-ryQofYOLa" /></figure><h3>Embed</h3><p>To be frank, this feature is very handy when you write wikis based on some Figma designs, you can just switch to another tab from ClickUp itself. Not only Figma but also any HTML code / URL which you need to embed it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B5ezp5pipebzLanh" /></figure><h3>Mindmap</h3><p>The simplest method to plan, organize, and visualize your thoughts and ideas is to use mind mapping. And I’m sure you’ve seen mind maps at some point in your life.</p><p>A mind map is a hierarchical graphic centered on a single idea. It arranges data in a non-linear manner, making it easier to see and comprehend any topic.</p><p>In the below example, I used the Mind mapping feature to organize them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_vbob3wt_XtNc6Oq" /></figure><h3>ClickApps</h3><p>Last but not least, ClickApps enable you to completely customize your team’s / personal experience within each Workspace. You have tons of the 3rd party app which you can integrate with ClickUp</p><h3>Conclusion</h3><p>That is it for this article. I hope you found this article useful, if you need any help please let me know in the comment section.</p><p>Would you like to buy me a coffee, You can do it <a href="https://www.buymeacoffee.com/suhailkakar">here</a>.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a>.</p><p>👋 Thanks for reading, See you next time</p><p><em>This article is neither sponsored nor affiliated with ClickUp. This is my honest opinion about their app</em></p><p><em>Originally published at </em><a href="https://blog.suhailkakar.com/how-i-use-clickup-to-efficiently-organize-my-day"><em>blog.suhailkakar.com</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daa5807fb36d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide To Solidity: Blockchain Development]]></title>
            <link>https://javascript.plainenglish.io/a-beginners-guide-to-solidity-blockchain-development-fb3e00212dad?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb3e00212dad</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Tue, 05 Oct 2021 07:17:22 GMT</pubDate>
            <atom:updated>2021-10-05T07:17:22.274Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JzkzJcBXPvkJ4Nwn" /><figcaption>Photo by <a href="https://unsplash.com/@peiobty?utm_source=medium&amp;utm_medium=referral">Pierre Borthiry</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Solidity is an object-oriented, high-level programming language for creating smart contracts on the blockchain that automate transactions. The language was created by participants to the Ethereum project when it was proposed in 2014. This language is mostly used to make smart contracts on the Ethereum blockchain.</p><p>According to its documentation, “Solidity is a curly-bracket language. It is influenced by C++, Python, and JavaScript, and is designed to target the Ethereum Virtual Machine (EVM).”</p><p>Solidity is also considered a dialect of JavaScript. This implies that if you know JavaScript, learning Solidity should be simple. Before learning more about solidity let’s understand some basic terms of blockchain.</p><h3>Ethereum Virtual Machine</h3><p>The Ethereum Virtual Machine (EVM) is the Ethereum smart contract runtime environment. The Ethereum Virtual Machine is focused on providing security and allowing machines all around the world to execute programs.</p><p>Virtual machines effectively create a layer of abstraction between the code and the machine that executes it. It is required to promote software portability and to ensure that programs are isolated from one another and from their host.</p><p>The Ethereum Virtual Machine was created to serve as a runtime environment for Ethereum-based smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*dHgk2_5Zc0rBOZ_b.png" /></figure><h3>Smart Contract</h3><p>A smart contract is a decentralized program that responds to events by executing business logic. The exchange of money, delivery of services, unlocking of information controlled by digital rights management, and other forms of data manipulation, such as altering the name on a property title, are all possible outcomes of smart contract execution. Smart contracts are often written in Solidity.</p><p>Smart contract languages like Solidity cannot be directly executed by the Ethereum Virtual Machine. They are instead converted to low-level machine instructions called opcodes.</p><p>Now that you have an idea about EVM and Smart Contract, we can continue learning about the Solidity</p><h3>Environment Setup</h3><p>Before installing Solidity, you need to make sure that you have Node.js and NPM installed on your computer. To install node.js in your Linux (Ubuntu) you can follow this <a href="https://blog.suhailkakar.com/how-to-install-nodejs-and-npm-on-ubuntu">article</a>.</p><p>Once you have successfully installed Node.js and NPM in your machine, you can proceed to install Solidity compiler as below:</p><pre>sudo npm install -g solc</pre><p>The command above will install the Solcjs and make it available globally throughout the system. Now you can run</p><pre>solcjs --version</pre><p>If everything goes fine, you see something similar to below in your terminal</p><blockquote><em>You can also use an online editor called Remix IDE to Compile and Run your Solidity code.</em></blockquote><h3>Reserved Keywords</h3><p>Following are the reserved keywords in Solidity:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/0*zIH9yk1NNyF9kJJ4.png" /></figure><h3>Importing other files in Solidity</h3><p>Importing a file in Solidity is similar to JavaScript, to import a file you can simply write</p><p>All global symbols from the “file” are imported into the current global scope by the above statement. But if you want to create a new global symbol someName with all the global symbols from “file” as members, you can write</p><p>Just like other programming languages, Solidity support both single-line and multi-line comments.</p><ul><li>Start the line with // to include a single-line comment.</li><li>Start with /* and end with */ to include a multi-line comment.</li></ul><h3>Variables in Solidity</h3><p>There are mainly two types of variables available in Solidity.</p><ul><li><strong>Local Variables</strong>: Variables with values that will <strong>persist</strong> till the function is completed</li><li><strong>State Variables</strong>: Variables whose values are kept in a contract storage system permanently</li></ul><h4>State variable</h4><p>State variables store the value permanently in the contract storage. Each method should have its own scope, and state variables should be declared outside of any defined functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P8S3hSfbw00NCET2.png" /></figure><h4>Local Variable</h4><p>A local variable’s context is contained within the function, and it cannot be retrieved from outside of it. These variables are typically used to store temporary values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ycRsFDiktjnXLfNk.png" /></figure><h3>Operators in Solidity</h3><p>Operators are important in every programming language because they establish the groundwork for the programming. Similarly, the functionality of Solidity is also incomplete without the use of operators.</p><p>Solidity supports the following types of operators:</p><ul><li>Arithmetic Operators</li><li>Relational Operators</li><li>Logical Operators</li><li>Bitwise Operators</li><li>Assignment operators</li><li>Conditional Operators</li></ul><p>However, in this article, we are going to study only 3 of them but in a future article, I will try to explain all of them :)</p><h4>Arithmetic Operators</h4><p>These operators are used to perform mathematical operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*STkKGtqLrzKUBCv4.png" /></figure><h4>Relational Operators</h4><p>These operators are used to compare two values</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*e2uMzvoG1Zp09Hh3.png" /></figure><h4>Logical Operators</h4><p>These operators are used to combine two or more conditions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*u_Q_N2nzUzSbB_Ex.png" /></figure><h3>Conclusion</h3><p>That is it for this article. I hope you found this article useful, if you need any help please let me know in the comment section.</p><p>Would you like to buy me a coffee, You can do it <a href="https://www.buymeacoffee.com/suhailkakar">here</a>.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a>.</p><p>👋 Thanks for reading, See you next time</p><p><em>Originally published at </em><a href="https://blog.suhailkakar.com/a-beginners-guide-to-solidity-blockchain-development"><em>blog.suhailkakar.com</em></a></p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb3e00212dad" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/a-beginners-guide-to-solidity-blockchain-development-fb3e00212dad">A Beginner’s Guide To Solidity: Blockchain Development</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Web 3.0 — Everything you need to know about Web 3.0 before learning it]]></title>
            <link>https://medium.com/geekculture/the-ultimate-guide-to-web-3-0-everything-you-need-to-know-about-web-3-0-before-learning-it-3cfa25a1ef14?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cfa25a1ef14</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[website]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Sun, 26 Sep 2021 13:57:33 GMT</pubDate>
            <atom:updated>2021-09-28T16:21:17.414Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Ultimate Guide to Web 3.0 — Everything you need to know about Web 3.0 before learning it</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*prfusj5fkO56I4Py" /><figcaption>Photo by <a href="https://unsplash.com/@oskaryil?utm_source=medium&amp;utm_medium=referral">Oskar Yildiz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You’ve probably heard about Web3 unless you’ve been living under a rock. Web 3.0 is the next step in the web’s growth, and it aims to make the internet more intelligent. Before learning more about Web3, let’s understand the evolution of the web first.</p><p>Over the last few years, the World Wide Web has developed, bringing with it new tools and strategies. Web 1.0, 2.0, and 3.0 are typical names for these stages. Now let’s understand each of their stags.</p><h3>Web 1.0</h3><p>It is the first stage in the evolution of the web, which is also referred as the read-only web. Web 1.0 websites were not as dynamic and interactive as it is now. The primary goal of the websites was to make the information available to the general public. As servers were improved, average connection speeds rose, and developers gained new skills and techniques, the shift from Web 1.0 to 2.0 took occurred over time.</p><h3>Web 2.0</h3><p>It is the second stage in the evolution of the web, which is also referred as the read-write web. It’s just a better version of the first worldwide web, marked by the shift from static to dynamic or user-generated content, as well as the rise of social media.</p><blockquote>Web 2.0 is the business revolution in the computer industry caused by the move to the internet as a platform, and any attempt to understand the rules for success on that new platform. — Tim O’Reilly.</blockquote><p>Some of the famous Web 2.0 applications are Google Maps, Facebook, Twitter, YouTube, WordPress and etc. Web technologies such as HTML5, CSS3, and Javascript frameworks such as ReactJs, AngularJs, VueJs, and others enable users to come up with new concepts, allowing users to contribute more to this Social Web.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY6nx2qbBI8ZaXFKLf5iZg.png" /></figure><p>Now that you have a good understanding of the evolution of the web and its old stages, Let’s understand, What is hell is this Web 3.0.</p><h3>Web 3.0</h3><p>It is the third stage in the evolution of the web, which is also referred as the read-write-execute which refers to the future of the web. In this era, artificial Intelligence and Machine Learning enable computers to understand data in the same way that people do.</p><p>Web3 applications or DApps, are developed on decentralized peer-to-peer networks like Ethereum and IPFS. These networks are developed, operated, and maintained by their users, rather than by a business. They self-organize and don’t have a single point of failure.</p><p>You’ll notice that when you hear about Web3, cryptocurrencies are frequently mentioned. This is due to the fact that many of these protocols include cryptocurrencies. Anyone who wishes to help create, control, or improve one of the projects is given a cash incentive (tokens).</p><p>These protocols frequently provide a wide range of services, including computation, storage, bandwidth, identification, hosting, and other online services previously supplied by cloud providers.</p><h3>What makes Web 3.0 so unique?</h3><p>Web 3’s major benefit is that it seeks to solve the most serious issue that has arisen as a result of Web 2: the gathering of personal data by private networks, which is subsequently sold to marketers or potentially stolen by hackers.</p><p>Web 3’s network is decentralized, meaning it is not controlled by a single organization, and the decentralized applications (apps) created on top of it are open.</p><h3>Properties of Web 3.0</h3><p>The following are three key characteristics that can help us define Web 3.0:</p><h4>Semantic Web</h4><p>One of the key elements of Web 3.0 is “semantic web.”. The semantic web enhances online technologies by allowing users to create, share, and connect content via search and analysis based on the ability to understand the meaning of words rather than keywords or numbers.</p><h4>3D Graphics</h4><p>3D Graphics is being used widely in websites and services in Web 3.0 such as online games, e-commerce, and portfolio website. <a href="https://bruno-simon.com/">Here</a> is the best example of a 3d website by Bruno Simon.</p><h4>Artificial Intelligence</h4><p>Semantic Web and Artificial Intelligence are the two cornerstones of web 3.0. By combining this capacity with natural language processing, Web 3.0 allows computers to comprehend material in the same way that people do, resulting in quicker and more relevant results. To meet the demands of users, they grow increasingly intelligent.</p><h3>What is Web3.js</h3><p>The Web3.js library is the primary JavaScript library you’ll use while creating Web3 applications. web3.js is a set of libraries that let you use an HTTP or IPC connection to communicate with a local or distant ethereum node.</p><p>The Ethereum blockchain is accessed with the web3 JavaScript library. It can access user accounts, send transactions, and communicate with smart contracts, among other things. In fact, Web3.js is one of the main frameworks used in designing dApps.</p><h3>Conclusion</h3><p>That is it for this article. I hope you found this article useful, if you need any help please let me know in the comment section.</p><p>Would you like to buy me a coffee, You can do it <a href="https://www.buymeacoffee.com/suhailkakar">here</a>.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a>.</p><p>👋 Thanks for reading, See you next time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cfa25a1ef14" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/the-ultimate-guide-to-web-3-0-everything-you-need-to-know-about-web-3-0-before-learning-it-3cfa25a1ef14">The Ultimate Guide to Web 3.0 — Everything you need to know about Web 3.0 before learning it</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide To Gatsby]]></title>
            <link>https://javascript.plainenglish.io/the-ultimate-guide-to-gatsby-57b6622d1726?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/57b6622d1726</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[gatsbyjs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 07:59:18 GMT</pubDate>
            <atom:updated>2021-09-12T07:59:18.107Z</atom:updated>
            <content:encoded><![CDATA[<h4>Everything You Need To Know Before Starting with Gatsby</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_TK0-M9hJXeqvBaR" /><figcaption>Photo by <a href="https://unsplash.com/@joshuaryanphoto?utm_source=medium&amp;utm_medium=referral">Joshua Reddekopp</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Gatsby websites are getting popular day by day. Nowadays most of the popular websites use Gatsby because of its speed, SEO and etc, and if you don’t know anything about Gatsby, It is probably worth learning it in 2021.</p><h3>What is Gatsby?</h3><p>GatsbyJS is a React-based, GraphQL powered static site generator. Gatsby is an open-source framework that combines functionality from React, GraphQL, and Webpack into a single tool for building static websites and apps. Although the term “static site generator” has been around for a while, Gatsby is more akin to a modern front-end framework than a traditional static site generator.</p><h3>What are Static Sites?</h3><p>Static websites have existed for a long time. They’re most likely the initial website, with only HTML, CSS, and JavaScript. They aren’t rendered in real-time because there isn’t any server-side programming, no database, and so on.</p><p>A static site generator is a tool that creates static web pages. JS frameworks and libraries, on the other hand, typically produce HTML content on the client-side during runtime. This material is generated by static site generators while the site is being built. Then, after it’s loaded, React takes over, and you’ve got yourself a single-page app!</p><h3>Why you should consider using Gatsby?</h3><h4>SEO</h4><p>The use of GatsbyJS allows your websites to make use of several of the internal code’s optimization strategies. As a result, search engines will rank your website higher. There are a number of plugins that can assist you with this.</p><h4>Plugins</h4><p>Gatsby has some amazing plugins which can help your website in different aspects. You can install these plugins using NPM or Yarn.</p><p>Some of the popular plugins are Source File-System, Contentful, Plugin Sharp and etc. You can find all plugins on their official website <a href="https://www.gatsbyjs.com/plugins">here</a>.</p><h4>Speed</h4><p>Gatsby sites are much faster than many of the alternatives, even compared to cached sites using WordPress and things like that because that static site is really hard to beat in terms of its speed and performance.</p><h4>Templates</h4><p>There are enough GatsbyJS Starter repositories and templates available that cloning and altering the content is straightforward. This allows you to quickly and efficiently construct websites such as your blog or your portfolio.</p><h3>Why should you avoid Gatsby?</h3><h4>Build Time</h4><p>As the amount of content on your website grows, so does the time it takes to produce it. This is not only inconvenient during development, but it also wastes time when it comes to deployment. Gatsby is not advised if you want to create a site that changes frequently.</p><h4>Dynamic Websites</h4><p>Sites with a lot of dynamically produced routes, because you won’t be able to reap the benefits of statically generated pages if you don’t know what they are at the time of construction.</p><h4>Complex sites</h4><p>Because complex sites expand quickly and take a long time to build, they are continuously adding new pages and material. Although many e-commerce companies can and do employ statically created sites, if build time becomes an issue, it is most likely time to abandon them in favor of dynamically generated sites like Gatsby.</p><h3>Set Up Your First Gatsby Website</h3><h4>Installing Gatsby CLI</h4><p>The first step is to install Gatsby CLI, You can create and modify a new site using the Gatsby command-line interface. To install Gatsby CLI, simply run :</p><pre>npm install -g gatsby-cli</pre><p>The -g argument indicates that the Gatsby command-line interface is being installed globally rather than locally. As a result, you&#39;ll be able to utilize the tool in any directory.</p><h4>Starter Templates</h4><p>As I mentioned previously that you don’t need to create a website from scratch, instead we can use some starter templates which can be found on Gatsby’s official website.</p><p>For this tutorial, we will use gatsby-starter-default to do that, run the below command on your terminal.</p><pre>gatsby new gatsby-starter-default https://github.com/gatsbyjs/gatsby-starter-default</pre><p>gatsby new creates a new website. You&#39;ll get a barebones site if you utilize gatsby new on its own. Combining gatsby new with a starter template is the most typical approach to use it.</p><h4>Run your app locally</h4><p>Once it is done, you should see a message that Gatsby site has been successfully bootstrapped. Now run</p><pre>cd gatsby-starter-default &amp;&amp; gatsby develop</pre><p>This command with navigate to our new gatsby folder and initialize files, so that we can view it locally. Open your browser and navigate to http://localhost:8000/, You should see a default stater page, just like image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGhFBrBA-VuT7pCmhfB70g.jpeg" /></figure><p>It’s critical to arrange your website’s metadata correctly if you want a search engine to find your website. The gatsby-config.js file allows you to customize your website’s data.</p><p>In order to make your website accessible for everybody around the globe, you need to deploy your website in a hosting service. You can deploy a Gatsby website to Netfliy, Vercel, Azure, Gatsby Cloud, Heroku, AWS, IIS, Firebase and etc. But for this example, we will use Netlify</p><h4>Deploying Website To Netlify</h4><p>Before deploying our website, first, we need to generate a build folder that contains static files. To do that run</p><pre>gatsby build</pre><p>Once it is completed, You should see a folder named public. That is it, We need only that folder to deploy in Netlify.</p><p>Go to <a href="https://www.netlify.com/">Netlify</a> website and if you don’t have an account, click on the signup button and create an account. Don’t worry, Netfliy is free hosting and it won’t charge you anything. Once you registered, you should be redirected to Netfliy dashboard, which will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zaIPoN2X9gq6Wm1s" /></figure><p>Now click on sites on the Netlify menu, and you should see a page with a text “Want to deploy a new site without connecting to Git? Drag and drop your site output folder here” . Drag and drop your public folder on that placeholder, Wait for a while and then your website will be deployed on Netfliy. If it is deployed successfully you should see something similar to the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q2moxu-1CWvQJAVq" /></figure><h3>Conclusion</h3><p>I hope you found this article helpful. If you need any help please let me know in the comment section.</p><p>Would you like to buy me a coffee, You can do it <a href="https://www.buymeacoffee.com/suhailkakar">here</a>.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a>.</p><p>👋 Thanks for reading, See you next time.</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57b6622d1726" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/the-ultimate-guide-to-gatsby-57b6622d1726">The Ultimate Guide To Gatsby</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Chrome Extensions That You Wish You Knew It Earlier]]></title>
            <link>https://suhailkakar.medium.com/top-chrome-extensions-that-you-wish-you-knew-it-earlier-4984c24e1302?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4984c24e1302</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Thu, 19 Aug 2021 06:35:18 GMT</pubDate>
            <atom:updated>2021-08-19T06:35:18.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*68BSOtkekxWOg6rW" /><figcaption>Photo by <a href="https://unsplash.com/@firmbee?utm_source=medium&amp;utm_medium=referral">Firmbee.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Chrome is a fantastic browser — it’s quick, well-designed, and jam-packed with useful features — but that’s only the beginning. Chrome’s true strength lies in its vast library of add-ons, which provide it with a never-ending supply of new features and capabilities.</p><p>In this article, I am going to introduce you top extensions that you might not know about them.</p><h3>10. Fake Filler</h3><p>Fake Filler is a form filler that fills all inputs on a page with scam/dummy data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ieMLhZFnAzjqzxFK.png" /></figure><h3>9. ColorPick Eyedropper</h3><p>A zoomed eyedropper &amp; color chooser tool that allows you to select color values from web pages and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VAAVfkE-IbGmX3ga.png" /></figure><h3>8. Site Palette</h3><p>A must-have tool for designers and front-end developers to grab colors for any website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wdVaacSl4gTI52Ou.png" /></figure><h3>7. WhatFont</h3><p>The easiest way to identify fonts on web pages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ARZ4REwfb4-JSy6j.png" /></figure><h3>6. Responsive Viewer</h3><p>Show multiple screens once, Responsive design tester</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KHu0WqlDEwYUgOom.png" /></figure><h3>5. PerfectPixel</h3><p>Adds a semi-transparent image overlay over the top of the developed HTML to easily perform pixel-perfect comparisons between them, useful for replicating UI designs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*93dUpjwAFOsN5XLH.png" /></figure><h3>4. Imageye</h3><p>Find and download all images on a web page. With Imageye you can find, browse and download all the images present on a web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kLfiXGUbWv169BEV.png" /></figure><h3>3. Stylebot</h3><p>Change the appearance of the web instantly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6IVyCF5MtsGTfF6O.png" /></figure><h3>2. Page Ruler Redux</h3><p>A Web Developer\Designer ruler to get perfect pixel dimensions and positioning to measure elements on any web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nL8fUsHdvQsJkhOX.png" /></figure><h3>1. Web Developer</h3><p>Adds a toolbar button with various web developer tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P_He18q_-7j2Kvaw.png" /></figure><h3>Conclusion ⌛</h3><p>I hope you found this short list helpful. If you need any help please let me know in the comment section.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a></p><p>👋 Thanks for reading, See you next time</p><p><em>Originally published at </em><a href="https://blog.suhailkakar.com/top-chrome-extensions-that-you-wish-you-knew-it-earlier"><em>https://blog.suhailkakar.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4984c24e1302" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Using ../../../ While Importing Components, Instead Use This Method]]></title>
            <link>https://suhailkakar.medium.com/stop-using-while-importing-components-instead-use-this-method-3cfa3b582fa6?source=rss-62c589bb40e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cfa3b582fa6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Suhail Kakar]]></dc:creator>
            <pubDate>Mon, 16 Aug 2021 05:16:14 GMT</pubDate>
            <atom:updated>2021-08-16T05:16:14.337Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stop Using ../../../ While Importing Components, Instead Use This Method</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QWGECkoYM3liPaFX" /><figcaption>Photo by <a href="https://unsplash.com/@jodaarba?utm_source=medium&amp;utm_medium=referral">Jose Aragones</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction 📚</h3><p>When you go to GitHub and see some other developers code, most of them are importing their components like this👇</p><pre>import Button from “../../../components/Buttons/Button”</pre><p>This is called relative import. Relative import will start with either ./,/ or ../.</p><p>I am not telling that this is the wrong way and even there is no issue if you import like that, but if you have a very big and complex project, relative imports will look a lot messy similar to this.</p><pre>import Button from &quot;../../../../../../components/Buttons/Button&quot;</pre><p>However, there is a very better and cleaner way to import these components. This method is called absolute import. An absolute import will look this like</p><pre>import Button from &quot;components/Buttons/Button&quot;</pre><h3>Adding absolute imports to React Apps (CRA) 💡</h3><p>Open your project in any code editor and create a new file in your project’s root directory named jsconfig.json. Once you created the file paste the below JSON inside of it.</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;src&quot;<br>  }<br>}</pre><p>This will instruct Webpack to use the src directory as a base one.</p><h3>Conclusion ⌛</h3><p>I hope you found this short article helpful. If you need any help please let me know in the comment section.</p><p>Let’s connect on <a href="https://twitter.com/suhailkakar">Twitter</a> and <a href="https://www.linkedin.com/in/suhailkakar/">LinkedIn</a></p><p>👋 Thanks for reading, See you next time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cfa3b582fa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>