<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Node.js Archives - asap developers</title>
	<atom:link href="https://www.asapdevelopers.com/category/node-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.asapdevelopers.com/category/node-js/</link>
	<description>San Francisco Mobile App Developers</description>
	<lastBuildDate>Mon, 25 Oct 2021 20:29:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://www.asapdevelopers.com/wp-content/uploads/2017/04/favicon-asap-1.png</url>
	<title>Node.js Archives - asap developers</title>
	<link>https://www.asapdevelopers.com/category/node-js/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Build a Global Activity Feed with React Native and Node.js</title>
		<link>https://www.asapdevelopers.com/build-a-global-activity-feed-with-react-native-and-node-js/</link>
		
		<dc:creator><![CDATA[Joaquin Viera]]></dc:creator>
		<pubDate>Mon, 25 Oct 2021 20:15:50 +0000</pubDate>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[React Native]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=14963</guid>

					<description><![CDATA[<p>People around the globe use Facebook, Instagram, Pinterest, Twitter and many other popular applications every day. They’re all used for different purposes like staying in touch with friends, creating blogs,...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/build-a-global-activity-feed-with-react-native-and-node-js/">Build a Global Activity Feed with React Native and Node.js</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[


<p>People around the globe use Facebook, Instagram, Pinterest, Twitter and many other popular applications every day. They’re all used for different purposes like staying in touch with friends, creating blogs, posting pictures, or discovering ideas. However, one thing that users of these apps have in common is that every single day they scroll through the apps’ activity feeds searching for new updates. A global activity feed is like a forum where users can post photos or make comments, as well as keep track of recent news or friends and family&#8217;s lives. In this article, we’ll be focusing on how to build one using React Native and Node.js. </p>









<h2><img decoding="async" loading="lazy" class="size-medium wp-image-14970 aligncenter" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/hamburger-menu-300x268.png" alt="Image1 - Global activity" width="300" height="268" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/hamburger-menu-300x268.png 300w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/hamburger-menu.png 360w" sizes="(max-width: 300px) 100vw, 300px" /></h2>



<h2><strong>Before we start</strong></h2>



<p>Adding a global activity feed to a mobile application sounds difficult, but, luckily for us, there are third-party libraries to help us, which is one of the things that we like most about React Native.</p>



<p>Today, we’ll use <a href="https://github.com/GetStream/react-native-activity-feed"><strong>react-native-activity-feed</strong></a> and also, as the documentation states, we’ll need to include the <a href="https://github.com/ivpusic/react-native-image-crop-picker"><strong>react-native-image-crop-picker</strong></a> if we are using native packages or <a href="https://docs.expo.dev/versions/latest/sdk/imagepicker/"><strong>expo-image-picker</strong></a> if we are using Expo.</p>



<p>To install all of these libraries, run the following scripts on your terminal from your React Native root project folder.</p>



<p>If you are using Expo:</p>



<ul>
<li>expo install expo-activity-feed expo-permissions expo-image-picker</li>
</ul>



<p>If you are using native packages:</p>



<ul>
<li>npm install react-native-activity-feed <strong>OR</strong> yarn add react-native-activity-feed</li>
<li>npm install react-native-image-crop-picker <strong>OR</strong> yarn add react-native-image-crop-picker</li>
</ul>



<p>Remember that, if you are using Xcode, every time you add new libraries to your project you have to run <strong>npx pod-install </strong>to install pods dependencies.</p>



<p><strong>Important note</strong>: to use react-native-activity-feed you need to have a GetStream account (we’ll look at this in the following steps). That said, GetStream provides <a href="https://getstream.io/activity-feeds/pricing/"><strong>paid plan options</strong></a> to use its resources; you can still use the Activity Feed package for free for development purposes, but only for a limited time.</p>



<h2><strong>Let’s jump into the code of a Global Activity Feed using React Native</strong></h2>



<p>First of all, you need to create a React Native project.</p>



<p>If you don&#8217;t know how to create your app, just run the following commands on your terminal:</p>



<ul>
<li><a href="https://reactnative.dev/docs/environment-setup"><strong>npx react-native init ProjectName</strong></a></li>
</ul>



<p>Now that you’ve created the application, let’s get to coding!</p>



<p><strong>Important note: </strong>this example was made using React Native 0.66.</p>



<h3> </h3>



<h3><strong>First steps</strong></h3>



<p>First, we need to create an account on <a href="https://getstream.io/accounts/signup/"><strong>https://getstream.io/accounts/signup/</strong></a></p>



<p>After signing up, we’ll navigate to our dashboard where we’ll see that an application has already been created for us. This app includes an App ID, a Key and a Secret Key. We will use those values later.</p>



<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone" src="https://lh6.googleusercontent.com/qViCDXFGAb2gbLjAwve_NGmfuji3yoLpAF-Hg3-d1zcJJcTnYZAEp51ezD4Dn6cWLPK9wJ4AaUdvE-IYpcfTCZS1UQLkZf3y_slZbd0Mf4QFL6poas7AmQR1IdsMxvj2pSBjl003=s1600" alt="global activity feed using react native" width="596" height="403" /></figure>



<p>By clicking on “PRODUCTION APP”, we can access our ‘Feeds’, access keys and other information. Note that we can create new feeds in this section.</p>



<h3><strong>Express backend client</strong></h3>



<p>It is very important to know that we can’t use our Secret Key inside a desktop/mobile/web environment, so we need a backend client.</p>



<p>Therefore, in a separate folder from the one containing the mobile project, we will run <strong>npm init </strong>in our console and provide a project name (e.g.: backend-server).</p>



<p>Inside this folder we need to install the two libraries using the following commands:</p>



<ul>
<li>npm install express &#8211;save</li>
<li>npm install getstream</li>
</ul>



<p>&nbsp;</p>

<p><script src="https://gist.github.com/joaquin-viera/b0ec34861539bd6c41f53fc993715dda.js"></script></p>
<p><b>Link:</b> <a href="https://gist.github.com/joaquin-viera/b0ec34861539bd6c41f53fc993715dda"><span style="font-weight: 400;">Backend.js</span></a></p>

<p>This Express server is very minimalist and its main purpose is to allow us to create a user token for the frontend application. Keep in mind that we are always creating and or getting and subscribing to the feed using a user with id ‘tester’. If we want to add more users, we can change this or send the param inside a query param.</p>



<p>With the server running, now we have to fetch a request to, in this case, <a href="http://localhost:3000">http://localhost:3000</a> from the mobile application.</p>



<h3><strong>Mobile application</strong></h3>



<p>&nbsp;</p>
<p><script src="https://gist.github.com/joaquin-viera/d92f90dad3ac2e717c8ac607f7f6ac03.js"></script></p>
<p><b>Link:</b> <a href="https://gist.github.com/joaquin-viera/d92f90dad3ac2e717c8ac607f7f6ac03"><span style="font-weight: 400;">App.js</span></a></p>

<p>In this example, we have an activity indicator running while we get the user access token to start our StreamApp. The only two values we have here are the STREAM_API_KEY and STREAM_APP_ID; the token is the one that we got from the backend.</p>



<p>GetStream provides <a href="https://github.com/GetStream/react-native-activity-feed/tree/master/src/components">many components</a> to use and customize. The most important one to establish the connection to our feed is <strong>StreamApp</strong>, which includes the API key, the app ID and a private token. We also need to send our user ID to see our user information in the post we create.</p>



<p>We can customize our feed however we want. We can also copy/paste the GetStream components to our code and make some modifications. In this example, we’ll customize the UserBar component for every Activity, and we’ll also add a LikeButton easily and in just a few lines as you can see in the link above!</p>



<p>Finally, we will see how the notify prop on the FlatFeed component shows that, every time there is a new post available, we will be notified and can tap on the notification area to see the new posts. If we prefer swiping down to update the feed, we can set the notify prop to false.</p>



<h2> </h2>



<h2><strong>Global Activity Feed preview</strong></h2>





<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone  wp-image-14971" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone1AG-143x300.png" alt="global activity feed - image1" width="288" height="604" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone1AG-143x300.png 143w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone1AG.png 220w" sizes="(max-width: 288px) 100vw, 288px" /><img decoding="async" loading="lazy" class="alignnone  wp-image-14972" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone2AG-143x300.png" alt="global activity feed - image2" width="288" height="604" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone2AG-143x300.png 143w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone2AG.png 255w" sizes="(max-width: 288px) 100vw, 288px" /><img decoding="async" loading="lazy" class="alignnone  wp-image-14979" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone3AG-1-142x300.png" alt="phone2 - global activity feed" width="286" height="604" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone3AG-1-142x300.png 142w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone3AG-1.png 322w" sizes="(max-width: 286px) 100vw, 286px" /></figure>
<p>&nbsp;</p>
<p>&nbsp;</p>



<figure class="wp-block-image"></figure>



<h2><strong>Final thoughts on building a Global Activity Feed using React Native</strong></h2>



<p>As we&#8217;ve seen, adding an activity feed to our <a href="https://www.asapdevelopers.com/react-native-san-francisco/">React Native</a> application can be done with just a few lines of code and it is not as hard as it might seem.</p>



<p>The best advantages of this library are that it is easy to use, it is easy to adapt and customize to our designs, and it provides many other features to use in our development projects.</p>

		<div id="fws_693975e15556a"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row top-level standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/react-native-san-francisco/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>Mobile App Development Company</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/build-a-global-activity-feed-with-react-native-and-node-js/">Build a Global Activity Feed with React Native and Node.js</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Build a React Native Login app with Node.js Backend</title>
		<link>https://www.asapdevelopers.com/build-a-react-native-login-app-with-node-js-backend/</link>
		
		<dc:creator><![CDATA[Agustin Fernandez]]></dc:creator>
		<pubDate>Mon, 28 Jun 2021 19:46:40 +0000</pubDate>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[React Native]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=14636</guid>

					<description><![CDATA[<p>&#160; In this guide, we will cover how to connect React Native and Node.js to develop a login application. Once logged in, users will be able to access a private...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/build-a-react-native-login-app-with-node-js-backend/">Build a React Native Login app with Node.js Backend</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>&nbsp;</p>



<p>In this guide, we will cover how to connect React Native and Node.js to develop a login application. Once logged in, users will be able to access a private resource. We won&#8217;t go into too much detail, so you can get started as soon as possible.</p>



<p>Before we start, let’s take a look at why we chose to use these technologies. You should know that prior knowledge of both tools is required to complete this guide successfully.</p>



<h2><strong>Why React Native? </strong></h2>



<p>According to the official <a href="https://reactnative.dev/">docs</a>, “<em>React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces.</em>”</p>



<p>To put it more simply, React Native is the adaptation of React for native development. But let’s analyze what that really means.</p>



<p>React Native is a framework based on React that uses JavaScript to build mobile applications that render natively, for Android and iOS at the same time. </p>



<p>Therefore, this tool allows web developers to take advantage of React’s outstanding benefits and apply their prior JavaScript knowledge but, in this case, to target mobile platforms.</p>



<h2><strong>Why Node.js?</strong> </h2>



<p>The official <a href="https://nodejs.org/es/">documentation</a> claims that “<em>Node.js is a JavaScript runtime built with Chrome&#8217;s V8 JavaScript engine.</em>” </p>



<p>Being a runtime means it acts as an environment that allows you to execute, in this case, a JavaScript program on your machine. Moreover, it uses a non-blocking I/O model to respond to events from a user or from another application, which makes it lightweight and efficient.</p>



<p>Moreover, its package ecosystem, npm, has the greatest number of open-source libraries in the world.</p>



<p>Now that we know which technologies we are going to use, let&#8217;s get started.</p>



<h3><strong>Create the Node.js project</strong></h3>



<p>Let&#8217;s talk about our backend and what its role will be. It will receive requests from the frontend and, in turn, give a response according to the result of the data flow. Behind the scenes, it will be interacting with the database, creating the users when they sign up and verifying their credentials when they attempt to log in.</p>



<h3><strong>Requirements</strong></h3>



<p>To be able to follow this part of the guide, you must have Node installed. We will be using <em>node</em> v14.16.1 and the <em>npm</em> 6.14.12 version.</p>



<p>To store our users in the database, we will be using MySQL Community Server as well as MySQL Workbench, so you will need them both as well. You can use another database if you want. If you do, you can skip the next step. </p>



<h3><strong>How to setup MySQL </strong><img decoding="async" loading="lazy" src="https://lh3.googleusercontent.com/4iqxMheIU0bKjitZ085HqYrxdiOvwxFh_fexrF-jvxuipnkni4dENvlWpOvmmWSAk69c2X9VnilOHU45KV0L0VF731ttnxppHZ8qlkBJRb7l0ohYaZOL0aIzuSpX4k3dTCPUtCD0" width="29" height="29" /></h3>



<p>Start by downloading MySQL Community Server from their <a href="https://dev.mysql.com/downloads/">website</a>. Follow the installation instructions and that’s it. Then, MySQL Workbench will be needed to manage our database. Download it from the same site and install it. We will use versions 8.0.25 and 8.0.12, respectively.</p>



<p>When you have finished, you will see a MySQL local instance running. To connect to the database, click on that instance and you will be asked to enter a password. Remember the password, as well as the username and the port your local instance is running on. You will need that later. </p>



<p>Now, it’s time to create our database. Right click below “Schemas&#8221; and choose “Create schema”. We will name it “loginDB”, but you can choose whichever name you prefer. Click “Apply” and the database will be created. </p>



<p>In the left panel, you will see the database we have just created. Inside it, there is a “Tables” section. Right click it and select “Create table”. Select the configuration below and click “Apply” to finish the setup.</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/AKXBdC_nEsaDoELNT4VoEvYRoY8psEzsrTjItZRG_mlpPSeYOCFEhBaCe2HuWAcB_P-PfgdCP_Bei-mLXxzWRCnNvKWg3aLr9qA1NBuA9PJkRtvP1BTgQVTunFgacPu-OjJfbxV9" alt="" /></figure>



<p>Once you are done, you can start by creating the backend project and installing the necessary dependencies. </p>



<p>First, we will create a “loginApp” folder and, inside it, another one called “server” where our backend will be placed. Folder names are up to you, you can name them however you want. Then, run the <em>npm init </em>command to initialize <em>npm</em> and proceed to install the required dependencies listed below. To install them, we will be using <em>yarn</em> version 1.22.10 and running the <em>yarn add &lt;package_name&gt;</em> command. we will summarize what each dependency does below, in case you are not familiar with all of them.</p>



<figure class="wp-block-table">
<table>
<tbody>
<tr>
<td>Package</td>
<td>Version</td>
<td>Description</td>
</tr>
<tr>
<td>bcryptjs</td>
<td>2.4.3</td>
<td>Hashes and compares user passwords </td>
</tr>
<tr>
<td>express</td>
<td>4.17.1</td>
<td>Minimal and flexible framework to be used</td>
</tr>
<tr>
<td>jsonwebtoken</td>
<td>8.5.1</td>
<td>Generates and verifies request tokens</td>
</tr>
<tr>
<td>mysql2</td>
<td>2.2.5</td>
<td>Allows you to interact with the MySQL database</td>
</tr>
<tr>
<td>nodemon</td>
<td>2.0.7</td>
<td>Automatically restarts the application when file changes in the directory are detected</td>
</tr>
<tr>
<td>sequelize</td>
<td>6.6.2</td>
<td>ORM to be used</td>
</tr>
</tbody>
</table>
</figure>



<p>After installing them, go to your package.json file and, in the <em>scripts</em> section, change <em>start</em> from <em>node app.js</em> to <em>nodemon app.js</em>. You can now run <em>npm start</em> and <em>nodemon</em> will be activated.</p>



<p>Enough with the preparations, let’s code. In the “server” folder, create an app.js file that will initialize the application and create and hold the environment configuration. Place this in your file:</p>



<h4>app.js</h4>

<p><script src="https://gist.github.com/agustinfece/849b79e6a43fdbbdf0d74301c07b4326.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/849b79e6a43fdbbdf0d74301c07b4326"><span style="font-weight: 400;">script</span></a></p>

<p>From now on, pay close attention to the imports in each file to understand how they are connected. </p>



<p>As you may see, in the first line of our app.js, we are importing <em>express</em> and, at the bottom, we are specifying the port where our server will be listening for requests. Also, two files we haven’t talked about yet are being imported. app.js will connect what they provide to our application.</p>



<p>The first one is database.js and it is inside a “utils” folder. Here, we will create an instance of <em>sequelize</em> that will let us connect to our MySQL database. Copy the following content and replace your password where it says <em>YOUR_PASSWORD</em>.</p>



<h4>database.js</h4>

<p><script src="https://gist.github.com/agustinfece/fc9891e62aa048531ce3ab55fd607e45.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/fc9891e62aa048531ce3ab55fd607e45"><span style="font-weight: 400;">script</span></a></p>

<p>The second imported script is inside a “routes” folder and is named routes.js. This is the one that defines our API endpoints using <em>express</em>, as follows: </p>



<p>routes.js</p>

<p><script src="https://gist.github.com/agustinfece/8059754189c582a0d991149f3a2ed27c.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/8059754189c582a0d991149f3a2ed27c"><span style="font-weight: 400;">script</span></a></p>

<p>We are only going to use the first three endpoints, the other two are examples you may need to define a public route and a default one.</p>



<p>You may note that, in this script, another file came into play in the imports. Its name is auth.js and it is placed inside the “controllers” folder. This file contains the actions that get executed when those requests are received.</p>



<p>So let&#8217;s see what auth.js should include:</p>



<h4>auth.js</h4>

<p><script src="https://gist.github.com/agustinfece/1dfc5d8bbd3c2f0d42bd0bc82bebbbfa.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/1dfc5d8bbd3c2f0d42bd0bc82bebbbfa"><span style="font-weight: 400;">script</span></a></p>

<p>Again, looking at the imports, we can see that there are two new packages: <em>bcryptjs</em> and <em>jsonwebtoken</em>. </p>
<p>&nbsp;</p>



<p>There is also another file we haven’t seen yet. Let’s look at what it should include before continuing with auth.js. </p>



<p>The file name is user.js and it is inside a “models” folder. It should import the <em>sequelize </em>instance from the database.js file we already saw and, then, define the <em>users </em>table we are going to store. Copying this into your file will be enough:s</p>
<p>

</p>
<h4>user.js</h4>

<p><script src="https://gist.github.com/agustinfece/a5d6f50870058df7ff5e27aa8c25ba9d.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/a5d6f50870058df7ff5e27aa8c25ba9d"><span style="font-weight: 400;">script</span></a></p>
<p>&nbsp;</p>

<p>Going back to the auth.js file, we can see three functions are being exported: <em>signup</em>, <em>login</em> and <em>isAuth</em>. These will be in charge of resolving the requests defined in routes.js.</p>



<p><em>signup</em> registers users in the database. First, it checks if the email provided has already been registered. Then, if the email and password have been received, it hashes the password and stores the user in the database. </p>



<p><em>login</em> handles login requests. It starts by checking if the email corresponds to a database user. If that’s the case, it hashes the password and compares it to the user password in the database. If they match, it responds with a temporary secret token. </p>



<p><em>isAuth</em> asks for the secret token and, if it is provided, proceeds to verify it. If everything goes well, it will finally respond with the private resource. In this case, that resource will be just a message containing “here is your resource”. This is enough for our proof of concept.</p>



<p>That’s it. We are done for now. We have our server ready to respond to authentication requests in port 5000 after running <em>npm start</em>. You can test the endpoints defined using Postman or another tool of your choice.</p>



<p><strong>Create the React Native project</strong></p>



<p>It&#8217;s time to talk about the frontend and what its role in this project should be. It will receive the user input and send a request to the backend, to sign up or log in, depending on what the user has selected. Then, based on the backend response, it will show an error or success message to the user.</p>



<p>So let’s start coding. The <em>create-react-native-app</em> package will set up the project for you. First, run the following command to install it globally: <em>yarn global add create-react-native-app</em></p>



<p>Then, go to your “loginApp” folder and execute the command we’ve just installed by running <em>create-react-native-app mobile</em>. Again, we decided to use “mobile” as the name of the frontend app, but it’s up to you. </p>



<p>This step is optional since your app’s style is up to you. Inside your new “mobile” folder, create a new folder called “public” and another one named “images” inside it. That last folder will contain the background image for the app. We downloaded the one we will be using from <a href="https://www.freepik.com/free-vector/white-abstract-background_11852424.htm">here</a> and we had to rotate it to achieve a portrait orientation.</p>



<p>Then, create another folder inside “mobile” called “screens”. Inside it, create two files, “index.js” and “AuthScreen.js”. The first one will be the one that exports the screen like this:</p>



<h4>index.js</h4>

<p><script src="https://gist.github.com/agustinfece/56083e1b477a6c77921c438407d68dab.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/56083e1b477a6c77921c438407d68dab"><span style="font-weight: 400;">script</span></a></p>

<p>The second one will contain our unique screen, where the user can get authenticated. It will use <em>fetch</em> to send the user requests to the backend and return a message according to what it receives. There will be one request sending user input and creating the signup or login, and another one requesting the private resource. Once the user logs in, the resource request will automatically be triggered.</p>



<p>We will be using a single screen for the entire app to make it simpler, but you can try a different approach if you want. Copy its content to your AuthScreen.js file:</p>



<h4>AuthScreen.js</h4>

<p><script src="https://gist.github.com/agustinfece/16c420233703f3e622829ba24d527aa9.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/16c420233703f3e622829ba24d527aa9"><span style="font-weight: 400;">script</span></a></p>

<p>Finally, we need to import that screen to our App.js file and render it as follows:</p>



<h4>App.js</h4>

<p><script src="https://gist.github.com/agustinfece/b62d065d24ad099edcf8d7ab18f657fb.js"></script> <b>Link:</b> <a href="https://gist.github.com/agustinfece/b62d065d24ad099edcf8d7ab18f657fb"><span style="font-weight: 400;">script</span></a></p>
<p>&nbsp;</p>

<p>And that’s all. Just run <em>npm start</em> on the mobile directory and the frontend app will start running on port 3000. Then, proceed to use a virtual or real device to test how it communicates with the backend. You should see something like this:</p>





<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone wp-image-14649" src="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test1-139x300.png" alt="react native sign up" width="313" height="676" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test1-139x300.png 139w, https://www.asapdevelopers.com/wp-content/uploads/2021/06/test1.png 302w" sizes="(max-width: 313px) 100vw, 313px" /> <img decoding="async" loading="lazy" class="alignnone wp-image-14650" src="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test2-137x300.png" alt="node js login" width="308" height="674" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test2-137x300.png 137w, https://www.asapdevelopers.com/wp-content/uploads/2021/06/test2.png 299w" sizes="(max-width: 308px) 100vw, 308px" /></figure>



<p>Let’s test if it works:</p>





<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone wp-image-14655" src="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test3-138x300.png" alt="react native sign up verification" width="311" height="676" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test3-138x300.png 138w, https://www.asapdevelopers.com/wp-content/uploads/2021/06/test3.png 300w" sizes="(max-width: 311px) 100vw, 311px" /><img decoding="async" loading="lazy" class="alignnone wp-image-14656" src="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test4-136x300.png" alt="node js login verification" width="306" height="676" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test4-136x300.png 136w, https://www.asapdevelopers.com/wp-content/uploads/2021/06/test4.png 294w" sizes="(max-width: 306px) 100vw, 306px" /></figure>



<p>Let’s test error messages by creating a user with the same email and trying to log in with the wrong credentials:</p>





<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone  wp-image-14657" src="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test5-139x300.png" alt="" width="305" height="658" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test5-139x300.png 139w, https://www.asapdevelopers.com/wp-content/uploads/2021/06/test5.png 302w" sizes="(max-width: 305px) 100vw, 305px" /><img decoding="async" loading="lazy" class="alignnone wp-image-14658" src="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test6-140x300.png" alt="node js login error" width="307" height="658" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/06/test6-140x300.png 140w, https://www.asapdevelopers.com/wp-content/uploads/2021/06/test6.png 302w" sizes="(max-width: 307px) 100vw, 307px" /></figure>



<p>It works perfectly! After you finish this guide, your directory should look like this:</p>



<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone" src="https://lh6.googleusercontent.com/rycan7rVcPS6OY0icgW32A1DARqFYLljOEeQKtGtbJUmmtD3t8cebgi4xbbp5Or28yvaY5WOD5fbcuJwm4A1m8JnRPqC_O1uBU8qOmsTIfbZMsvMep2MMhhCJMSEbOikrzntXDXw" alt="react native" width="295" height="1092" /></figure>



<p>You have reached the end of this guide. Now you have a React Native frontend login application working with a Node.js backend. Congratulations!</p>



<h2><strong>Challenge: Develop tests for your React Native App </strong></h2>



<p>We encourage you to test your application on both sides to ensure it is working as expected. Testing is an essential part of any development process and you should start incorporating it into your projects from the beginning. </p>



<p>You can start with the frontend side, testing components in the way a user would use them. We recommend using <a href="https://testing-library.com/">React Testing Library</a>. If you haven’t heard about it, you can read the <a href="https://www.asapdevelopers.com/react-testing-library/">article</a> we have written about it.</p>



<h2><strong>Final thoughts on React Native with Node.js backend</strong></h2>



<p>To sum up, both React Native and Node.js are powerful tools that share a single programming language: JavaScript. With their separate advantages combined, you have built an incredibly strong mobile application. We have proven how straightforward it is to get started with any of them, even if you have not seen it before. We hope this guide gives you a starting point to start creating mobile apps with more functionalities.</p>



<p><a href="https://github.com/agustinfece/login"><strong>GitHub</strong></a></p>

		<div id="fws_693975e157688"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/react-native-san-francisco/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>React Native Development Company</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/build-a-react-native-login-app-with-node-js-backend/">Build a React Native Login app with Node.js Backend</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python vs Node.js</title>
		<link>https://www.asapdevelopers.com/python-vs-nodejs/</link>
		
		<dc:creator><![CDATA[Mirazoqui]]></dc:creator>
		<pubDate>Fri, 10 May 2019 12:43:42 +0000</pubDate>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=9849</guid>

					<description><![CDATA[<p>Which framework should you choose? Python vs Node.js: Choosing a language for back-end development is very important, as you will be using it to create your server-side applications. The server-side...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/python-vs-nodejs/">Python vs Node.js</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><strong>Which framework should you choose?</strong></h2>
<p><span style="font-weight: 400;">Python vs Node.js: Choosing a language for back-end development is very important, as you will be using it to create your server-side applications. The server-side is the engine that makes your application run; it will determine the performance and scalability of your application, in addition to other very important factors.</span></p>
<p><span style="font-weight: 400;">When it comes to building a project, there isn’t a one-fits-all solution, but we hope to provide you with enough information to help you make a decision on which software will adapt better to your needs. So today, we’ll compare Python vs Node.js in order to give you a better idea of what both are capable of and what kind of projects they work best for.</span></p>
<p><span style="font-weight: 400;">Python is an object-oriented high-level language and it can be used for general purpose programming language.Node.js is an environment that allows JavaScript code to run on the server side and not on a browser. It is based on Chrome’s V8 Engine, which runs on Google Chrome.</span></p>
<p><span style="font-weight: 400;"><img decoding="async" loading="lazy" class="aligncenter wp-image-9859 size-full" src="https://www.asapdevelopers.com/wp-content/uploads/2019/04/forest-path-238887.jpg" alt="Which path should you choose?" width="800" height="450" srcset="https://www.asapdevelopers.com/wp-content/uploads/2019/04/forest-path-238887.jpg 800w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/forest-path-238887-300x169.jpg 300w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/forest-path-238887-768x432.jpg 768w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/forest-path-238887-610x343.jpg 610w" sizes="(max-width: 800px) 100vw, 800px" /></span></p>
<p><span style="font-weight: 400;">Now let’s talk a closer look at the various aspects to consider when comparing Python vs Node.js:</span></p>
<h2><strong>Performance</strong></h2>
<p><span style="font-weight: 400;">Performance defines the speed of your back-end server responses, and that will depend, of course, on how fast your code is executed. Many studies have proven that Node.js is faster than Python. That’s because Node.js is based on Chrome’s V8 which is a very powerful and fast engine.</span></p>
<p><span style="font-weight: 400;">This means Node.js is an ideal solution for developing messaging or chat applications. It is also useful for <a href="https://www.asapdevelopers.com/python-development-company/">developing heavy-load applications</a> and e-commerce sites that depend on processing speed.</span></p>
<h2><strong>Usability</strong></h2>
<p><span style="font-weight: 400;">When it comes to comparing the amount of code that developers need to write, Python requires fewer lines of code. It is also an ideal solution for large projects due to its clean code standards, which Node.js lacks.</span></p>
<p><span style="font-weight: 400;">On the other hand, Node.js is pure JavaScript, meaning it remains basic and simple for developers to learn. It can also be used both on front-end and back-end, meaning developers don&#8217;t need to learn an entire new language with its own paradigms in order to program.</span></p>
<h2><strong>Versatility</strong></h2>
<p><span style="font-weight: 400;">Python is one of the most versatile programming languages suited for web development, artificial intelligence, machine learning, data analysis, etc. Although JavaScript is also good for web development, it is not well-suited for other future trends.</span></p>
<h2><strong>Error handling</strong></h2>
<p><span style="font-weight: 400;">Handling errors is one of the biggest activities that developers need to deal with. Both </span><a href="https://da-14.com/blog/seven-reasons-choose-nodejs-your-startup"><span style="font-weight: 400;">Node.js</span></a><span style="font-weight: 400;"> and Python deal well with throwing and catching exceptions, that is, errors occurring during code execution. Python takes significantly less time and debugging in Python is also fairly easy compared to Node.js. So, when it comes to error handling and debugging, Python trumps Node.js.</span></p>
<h2><strong><img decoding="async" loading="lazy" class="aligncenter wp-image-9856 size-full" src="https://www.asapdevelopers.com/wp-content/uploads/2019/04/asap_header-phyton-vs-nodejs.jpg" alt="Python vs Node.js" width="1920" height="550" srcset="https://www.asapdevelopers.com/wp-content/uploads/2019/04/asap_header-phyton-vs-nodejs.jpg 1920w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/asap_header-phyton-vs-nodejs-300x86.jpg 300w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/asap_header-phyton-vs-nodejs-768x220.jpg 768w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/asap_header-phyton-vs-nodejs-1024x293.jpg 1024w, https://www.asapdevelopers.com/wp-content/uploads/2019/04/asap_header-phyton-vs-nodejs-610x175.jpg 610w" sizes="(max-width: 1920px) 100vw, 1920px" /></strong></h2>
<h2><strong>Conclusion of Python vs </strong><strong>Node.js</strong></h2>
<p><span style="font-weight: 400;">We can’t say one language is better than the other. The reality is that you should think carefully about what you are trying to achieve, what your application needs to support and if either of these languages </span><span style="font-weight: 400;">—</span><span style="font-weight: 400;"> or any other language </span><span style="font-weight: 400;">—</span><span style="font-weight: 400;"> can adapt to your needs.</span></p>
<p><span style="font-weight: 400;">Both Node.js and Python have big communities so, if any issue arises, you can easily search for a solution to your problem or simply ask the community.</span></p>
<div id="fws_693975e158520"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/los-angeles-app-developers/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>Learn More About Our Services</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/python-vs-nodejs/">Python vs Node.js</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
