<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Ali (Nerdjfpb)</title>
    <description>The latest articles on DEV Community by Muhammad Ali (Nerdjfpb) (@nerdjfpb).</description>
    <link>https://dev.to/nerdjfpb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F217204%2F5d66fc09-f166-4a95-a5e1-94436bedbe7d.jpeg</url>
      <title>DEV Community: Muhammad Ali (Nerdjfpb)</title>
      <link>https://dev.to/nerdjfpb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nerdjfpb"/>
    <language>en</language>
    <item>
      <title>How to auto sort imports in frontend, example with typescript &amp; nextjs</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Mon, 12 Jun 2023 14:34:38 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-auto-sort-imports-in-frontend-example-with-typescript-nextjs-1oi4</link>
      <guid>https://dev.to/nerdjfpb/how-to-auto-sort-imports-in-frontend-example-with-typescript-nextjs-1oi4</guid>
      <description>&lt;p&gt;As a frontend developer, I import a lot of things on my every file and they look scary after a while! So I was looking for a way to solve this and I found a quick and easy solution which can use on any project I work on.&lt;/p&gt;

&lt;p&gt;There are multiple ways to do the sorting and I always look for the easy and I always do that.&lt;/p&gt;

&lt;p&gt;So here is an example of how I’m doing it in my &lt;code&gt;nextjs&lt;/code&gt; project. After creating a new &lt;code&gt;nextjs&lt;/code&gt; project. I install 2 packages –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;D&lt;/span&gt; &lt;span class="nx"&gt;prettier&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;trivago&lt;/span&gt;&lt;span class="sr"&gt;/prettier-plugin-sort-import&lt;/span&gt;&lt;span class="err"&gt;s
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I add a &lt;code&gt;.prettierrc&lt;/code&gt; for my project and it contains&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"singleQuote"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"importOrder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;THIRD_PARTY_MODULES&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"^@internal/(.*)$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"^[./].*(?&amp;lt;!&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;.(c|le|sc)ss)$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"^[.]/[-a-zA-Z0-9_]+[.](module)[.](css|scss|less)$"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"importOrderSeparation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"importOrderSortSpecifiers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"printWidth"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I went with my configuration you can go with one you like more. Find out more by &lt;a href="https://github.com/trivago/prettier-plugin-sort-imports"&gt;clicking here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I generally use vscode and I configured always use prettier for sorting (Also installed a prettier extension). This helps me to apply the prettier on each save.&lt;/p&gt;

&lt;p&gt;If you are using vscode just add this in your setting JSON file then it’ll apply prettier every time you save&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;editor.formatOnSave&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Source Code
&lt;/h2&gt;

&lt;p&gt;You can find it here – &lt;a href="https://github.com/nerdjfpb/auto-sort-import-example"&gt;https://github.com/nerdjfpb/auto-sort-import-example&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;Drop a dm on – &lt;a href="https://twitter.com/nerdjfpb"&gt;twitter&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to be part of an amazing programming community and participate in free programming events?
&lt;/h2&gt;

&lt;p&gt;Join our &lt;a href="https://discord.gg/WBvHdMCYC7"&gt;Discord server&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to hire me for your next project?
&lt;/h2&gt;

&lt;p&gt;Connect me with &lt;a href="https://www.linkedin.com/in/nerdjfpb/"&gt;linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>typescript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to use custom google font with react native expo, NativeBase and Typescript?</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Thu, 10 Mar 2022 15:48:46 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-use-custom-google-font-with-react-native-expo-nativebase-and-typescript-3jf7</link>
      <guid>https://dev.to/nerdjfpb/how-to-use-custom-google-font-with-react-native-expo-nativebase-and-typescript-3jf7</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Recently, I started working with a react native project with NativeBase. I feel like a custom font guide can be a little hard to understand, so I'm writing this blog to make things easier!&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre Requisite
&lt;/h2&gt;

&lt;p&gt;To follow along with the blog, you should know a few stuff -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React Basics&lt;/li&gt;
&lt;li&gt;React Native basics&lt;/li&gt;
&lt;li&gt;Expo Basics&lt;/li&gt;
&lt;li&gt;Typescript basics&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things I’m using
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vscode: for writing code&lt;/li&gt;
&lt;li&gt;Nodejs: for different commands &amp;amp; npm&lt;/li&gt;
&lt;li&gt;Packages

&lt;ul&gt;
&lt;li&gt;expo ts template: for creating react native app with ts&lt;/li&gt;
&lt;li&gt;expo-font: for using font in expo&lt;/li&gt;
&lt;li&gt;@expo-google-fonts/inter: google font inter&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  App initialization with expo and ts
&lt;/h2&gt;

&lt;p&gt;Let's start the app using - (install expo if that's not available in as global package)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;expo&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt; &lt;span class="nx"&gt;custom&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;font&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kd"&gt;with&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;ts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will open up&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;Choose&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;»&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;Use&lt;/span&gt; &lt;span class="nx"&gt;arrow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Return&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;submit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
    &lt;span class="o"&gt;-----&lt;/span&gt; &lt;span class="nx"&gt;Managed&lt;/span&gt; &lt;span class="nx"&gt;workflow&lt;/span&gt; &lt;span class="o"&gt;-----&lt;/span&gt;
    &lt;span class="nx"&gt;blank&lt;/span&gt;               &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;minimal&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;clean&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;an&lt;/span&gt; &lt;span class="nx"&gt;empty&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;   &lt;span class="nx"&gt;blank&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;TypeScript&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="nx"&gt;same&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;blank&lt;/span&gt; &lt;span class="nx"&gt;but&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nx"&gt;TypeScript&lt;/span&gt; &lt;span class="nx"&gt;configuration&lt;/span&gt;
    &lt;span class="nx"&gt;tabs&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;TypeScript&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="nx"&gt;several&lt;/span&gt; &lt;span class="nx"&gt;example&lt;/span&gt; &lt;span class="nx"&gt;screens&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;tabs&lt;/span&gt; &lt;span class="nx"&gt;using&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;TypeScript&lt;/span&gt;
    &lt;span class="o"&gt;-----&lt;/span&gt; &lt;span class="nx"&gt;Bare&lt;/span&gt; &lt;span class="nx"&gt;workflow&lt;/span&gt; &lt;span class="o"&gt;-----&lt;/span&gt;
    &lt;span class="nx"&gt;minimal&lt;/span&gt;             &lt;span class="nx"&gt;bare&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;minimal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;just&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;essentials&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="nx"&gt;started&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose &lt;code&gt;blank (TypeScript)&lt;/code&gt; because we will work with typescript! It'll take some time. Once it's done, let's install our UI component library &lt;code&gt;nativbase&lt;/code&gt; using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;yarn&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="nx"&gt;native&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;
&lt;span class="nx"&gt;expo&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;native&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;svg&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;native&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;safe&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;area&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install done. Now let's go to the &lt;code&gt;App.tsx&lt;/code&gt; file and add &lt;code&gt;native-base&lt;/code&gt;. The file will look like this -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NativeBaseProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Box&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;native-base&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;NativeBaseProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Box&lt;/span&gt; &lt;span class="na"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#fff"&lt;/span&gt; &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt; &lt;span class="na"&gt;justifyContent&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Hello world
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Box&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;NativeBaseProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's run it using &lt;code&gt;yarn start&lt;/code&gt;. We can run it on android, ios or the web. I'll run it in android, and it looks like -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--toNVJ1So--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akbpz68san5wpv6r6riw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--toNVJ1So--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akbpz68san5wpv6r6riw.png" alt="screenshot 1" width="434" height="872"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a default font family, its using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;font-family&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;-apple-system&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;BlinkMacSystemFont&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;"Segoe UI"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;Roboto&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;Helvetica&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nt"&gt;Arial&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;sans-serif&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add google font
&lt;/h2&gt;

&lt;p&gt;Now let's add some custom google font here! We are using expo, so we need to follow the expo way to installing custom google font -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;expo&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;expo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;font&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;expo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;google&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;fonts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;inter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I am using inter font, so I've installed it here. You can use other fonts as you want. Check the google fonts available by expo from &lt;a href="https://github.com/expo/google-fonts"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we've to load the font in our &lt;code&gt;App.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;useFonts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_100Thin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_200ExtraLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_300Light&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_400Regular&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_500Medium&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_600SemiBold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_700Bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_800ExtraBold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Inter_900Black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@expo-google-fonts/inter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NativeBaseProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Box&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;native-base&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;fontsLoaded&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useFonts&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_100Thin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_200ExtraLight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_300Light&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_400Regular&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_500Medium&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_600SemiBold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_700Bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_800ExtraBold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Inter_900Black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;fontsLoaded&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&amp;gt;&amp;lt;/&amp;gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;NativeBaseProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Box&lt;/span&gt; &lt;span class="na"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#fff"&lt;/span&gt; &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt; &lt;span class="na"&gt;justifyContent&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt; &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"2xl"&lt;/span&gt; &lt;span class="na"&gt;fontWeight&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"700"&lt;/span&gt; &lt;span class="na"&gt;textTransform&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"uppercase"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Custom Font App
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Box&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;NativeBaseProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can add the custom font, but they are not being used right now. If we look into the app, we'll use find the old font being used. So we need to improve that by changing the theme from native-base!&lt;/p&gt;

&lt;p&gt;Let's do it together. Add a &lt;code&gt;theme.ts&lt;/code&gt; file in the root and add the fonts there -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;extendTheme&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;native-base&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;extendTheme&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;fontConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Inter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_100Thin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_200ExtraLight&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_300Light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_400Regular&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_500Medium&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_600SemiBold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_700Bold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_800ExtraBold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter_900Black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="c1"&gt;// Make sure values below matches any of the keys in `fontConfig`&lt;/span&gt;
  &lt;span class="na"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;heading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;mono&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Inter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now just link the theme with our current &lt;code&gt;App.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./theme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NativeBaseProvider&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/NativeBaseProvider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can see the new font in our app. Let's rerun it by &lt;code&gt;yarn start&lt;/code&gt; and see the result -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_ahMt1B4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uty2eby5g8ip98po7ahv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_ahMt1B4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uty2eby5g8ip98po7ahv.png" alt="Screenshot 2" width="425" height="862"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is how we can add the google font easily with expo react native and nativebase!&lt;/p&gt;

&lt;h2&gt;
  
  
  Source Code
&lt;/h2&gt;

&lt;p&gt;You can find it from here - &lt;a href="https://github.com/nerdjfpb/custom-font-with-ts"&gt;https://github.com/nerdjfpb/custom-font-with-ts&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to take the project to the next level?
&lt;/h2&gt;

&lt;p&gt;Explore how I structure react code for working with a team (this will saves a ton of time) -&lt;br&gt;
&lt;a href="https://blog.nerdjfpb.com/how-to-add-eslint-prettier-and-husky-git-hook-in-react-js-2022"&gt;https://blog.nerdjfpb.com/how-to-add-eslint-prettier-and-husky-git-hook-in-react-js-2022&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;Drop a dm on - &lt;a href="https://twitter.com/nerdjfpb"&gt;twitter&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to be part of an amazing programming community and participate in free programming events?
&lt;/h2&gt;

&lt;p&gt;Join our &lt;a href="https://discord.gg/WBvHdMCYC7"&gt;Discord server&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to hire me for your next project?
&lt;/h2&gt;

&lt;p&gt;Connect me with &lt;a href="https://www.linkedin.com/in/nerdjfpb/"&gt;linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Random Password Generator – Learn Modern React JS By Projects For FREE In 2022</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Fri, 25 Feb 2022 21:20:01 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/random-password-generator-learn-modern-react-js-by-projects-for-free-in-2022-1234</link>
      <guid>https://dev.to/nerdjfpb/random-password-generator-learn-modern-react-js-by-projects-for-free-in-2022-1234</guid>
      <description>&lt;p&gt;Learning React js changed my life completely. I got many freelancing opportunities and my current remote job because I was skilled in React. I want to help others, so I'm creating this tutorial series to make some react projects for beginners to intermediate levels. It'll be focused on the Modern React js and how you'll write it in 2022. I'll come back and keep updating this tutorial if anything else changes. Also, I'll try to publish a new project/blog every upcoming week(from now), so &lt;a href="https://twitter.com/nerdjfpb" rel="noopener noreferrer"&gt;follow nerdjfpb&lt;/a&gt; for that. Let's dive into our very first blog -&lt;/p&gt;

&lt;h2&gt;
  
  
  What we are going to build
&lt;/h2&gt;

&lt;p&gt;This blog is the first tutorial of all series so we will build a random password generator here. Let's see how we can do it with react. We'll add some twists here and there!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bq8sabrtpomj72rchcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bq8sabrtpomj72rchcu.png" alt="screenshot1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Generate a random password&lt;/li&gt;
&lt;li&gt;Password will be copied to the clipboard&lt;/li&gt;
&lt;li&gt;Show a popup message when it copied to the clipboard&lt;/li&gt;
&lt;li&gt;Hosted in GitHub pages&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pre Requisite
&lt;/h2&gt;

&lt;p&gt;This blog is specific to reactjs, so you have to know a few things before following this -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Html, Css&lt;/li&gt;
&lt;li&gt;Javascript (Intermediate level)&lt;/li&gt;
&lt;li&gt;Basic Nodejs (how nodejs, npm works, scripts)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things I’m using
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Vscode&lt;/a&gt;: for writing code&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Nodejs&lt;/a&gt;: for different commands &amp;amp; npm&lt;/li&gt;
&lt;li&gt;Packages

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://create-react-app.dev/" rel="noopener noreferrer"&gt;create react app&lt;/a&gt;: for creating packages&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/react-toastify" rel="noopener noreferrer"&gt;react toastify&lt;/a&gt;: for showing the popup messages&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Starting a New React JS Project
&lt;/h2&gt;

&lt;p&gt;Let's start with exploring React js a little bit. We usually go through a boilerplate called &lt;code&gt;create-react-app&lt;/code&gt; to create a new react project. This one use webpack underhood. But nowadays &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;VITE&lt;/a&gt; is getting so popular and damn fast, so if you want to start your project with VITE, that can be a great choice too! But for this tutorial, we are going to go with the &lt;code&gt;create-react-app&lt;/code&gt;. Let's create a react project for our project -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npx&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;gen&lt;/span&gt; &lt;span class="c1"&gt;// replace react-password-gen with your project name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands will create a folder and don't get overwhelmed with lots of folders. Let's go through it one by one! But before that, I guess you have got a question in your mind, right? Why do we write &lt;code&gt;npx&lt;/code&gt; instead of npm? Normally we install anything using &lt;code&gt;npm install packageName&lt;/code&gt;, right? So why npx? npx is a tool for executing the npm packages. Confusing right? Read more from &lt;a href="https://stackoverflow.com/questions/50605219/difference-between-npx-and-npm" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's drive into our current situation. We have got a lot of folders. The time I'm making this &lt;a href="https://create-react-app.dev/" rel="noopener noreferrer"&gt;create-react-app&lt;/a&gt; comes with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules
public
src.gitignore
package - lock.json
package.json
README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ignore the node_modules because I guess you already know what's in there. Let's go to the public folder, and there are a few files -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;favicon.ico
index.html
logo192.png
logo512.png
manifest.json
robot.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't know any of these files, just try a simple google search. It's simple basic, and I'm not going to explain this! But let's have a look into the &lt;code&gt;index.html&lt;/code&gt; file -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"utf-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"%PUBLIC_URL%/favicon.ico"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"theme-color"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"#000000"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt;
      &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;
      &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Web site created using create-react-app"&lt;/span&gt;
    &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"apple-touch-icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"%PUBLIC_URL%/logo192.png"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"manifest"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"%PUBLIC_URL%/manifest.json"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;React App&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;noscript&amp;gt;&lt;/span&gt;You need to enable JavaScript to run this app.&lt;span class="nt"&gt;&amp;lt;/noscript&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"root"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, this HTML file is just a basic setup, and we have got an id root here. We are loading the react app from the &lt;code&gt;src&lt;/code&gt; folder inside this div. Let's have a look inside the &lt;code&gt;src&lt;/code&gt; folder now -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App.css
App.js
App.test.js
index.css
index.js
logo.svg
reportWebVitals.js
setupTests.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we'll make this minimal, and we'll have -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App.css
App.jsx // js to jsx
index.css
index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's start by exploring the &lt;code&gt;index.js&lt;/code&gt; file first. We are going to clean it up for now -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./index.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// import reportWebVitals from "./reportWebVitals";&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React.StrictMode&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// If you want to start measuring performance in your app, pass a function&lt;/span&gt;
&lt;span class="c1"&gt;// to log results (for example: reportWebVitals(console.log))&lt;/span&gt;
&lt;span class="c1"&gt;// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals&lt;/span&gt;
&lt;span class="c1"&gt;// reportWebVitals();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are loading &lt;code&gt;react&lt;/code&gt; &amp;amp; &lt;code&gt;react-dom&lt;/code&gt; later. We are just passing the &lt;code&gt;app&lt;/code&gt; component in place of the root. If you know javascript, then you already know what is happening here. We are going to write es6+ features which usually don't support in browser. So we use webpack/some other bundling tool to convert and make some modifications to serve well in the production. We need to support all major browsers; otherwise our creation will not reach everyone.&lt;/p&gt;

&lt;p&gt;CSS files are pretty straightforward, so I'm not going to go over those. Let's jump to &lt;code&gt;app.jsx&lt;/code&gt; file and delete all things from here and write some new stuff quick -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are using a &lt;code&gt;div&lt;/code&gt; HTML, so we are writing HTML inside a js function? Kind of yes. But it's not HTML; it calls JSX. Almost similar to HTML; it just has some changes. Look more at &lt;a href="https://reactjs.org/docs/introducing-jsx.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Project UI
&lt;/h2&gt;

&lt;p&gt;Let's start building our password generator app! We'll use this &lt;code&gt;app.js&lt;/code&gt; less complexity this time. Let's begin the design, and I hope you already know HTML and CSS, and this part is just like HTML &amp;amp; CSS -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;background&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Generate&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;random&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wrapper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;**********************&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;generate-password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Generate&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS part -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.background&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="m"&gt;43deg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="m"&gt;#4158d0&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="m"&gt;#c850c0&lt;/span&gt; &lt;span class="m"&gt;46%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="m"&gt;#ffcc70&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.heading&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;70px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;uppercase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt; &lt;span class="m"&gt;32px&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;38&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;135&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.37&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.18&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.password&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.generate-password&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our style is complete, and it looks exactly the same as the screenshot -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4ozkxp7r1g3zv6kfns1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4ozkxp7r1g3zv6kfns1.png" alt="Screenshot2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the State from React JS
&lt;/h2&gt;

&lt;p&gt;If you look into the &lt;code&gt;app.jsx&lt;/code&gt; file, it seems like we are writing HTML inside a javascript function, right? Yeah! That's right! But we are not writing HTML in the javascript file. We are writing jsx. We have some power over the HTML. But before that, let's go over a concept of how we will make this app. Steps are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First get a const variable for holding the password "*&lt;strong&gt;*****&lt;/strong&gt;***&lt;strong&gt;*****&lt;/strong&gt;"&lt;/li&gt;
&lt;li&gt;Then when button click it'll fire up the a function that'll change the password value&lt;/li&gt;
&lt;li&gt;Re-render the part with new value (something like innerHTML maybe?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But as, react worked based on its concept and has a virtual dom. So we will not follow how we update a dom value in vanilla javascript. React state is like a javascript variable that holds a value that can change. We will follow the hook instead of the old way of classes because the code looks cleaner and is easy to work on in the future. We need to call a useState function to get the state value for the password. So let's call it -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPassword&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;**********************&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// rest of the codes&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confusing right? We are using &lt;code&gt;useState&lt;/code&gt; function from react and passing so many stars. &lt;code&gt;useState&lt;/code&gt; is actually going put the "*&lt;strong&gt;*****&lt;/strong&gt;***&lt;strong&gt;*****&lt;/strong&gt;" in password variable and &lt;code&gt;setPassword&lt;/code&gt; is a function that'll help us to update the &lt;code&gt;password&lt;/code&gt; field. Checkout more on react website - &lt;a href="https://beta.reactjs.org/apis/usestate#usestate" rel="noopener noreferrer"&gt;it's a beta now(also incomplete), old docs can make you confused so better to follow it&lt;/a&gt; and also learn more about &lt;a href="https://beta.reactjs.org/learn/state-a-components-memory" rel="noopener noreferrer"&gt;state component&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's write the jsx for updating it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"generate-password"&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;generatePassword&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  Generate password
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So instead of a static value, now we got a state in password div. Now we can change it by clicking and firing the function &lt;code&gt;generatePassword&lt;/code&gt; -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;generatePassword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Create a random password&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;randomPassword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Set the generated password as state&lt;/span&gt;
  &lt;span class="nf"&gt;setPassword&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;randomPassword&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Copy the password to the clipboard&lt;/span&gt;
  &lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clipboard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;randomPassword&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Relatively straightforward, right? As we are just working with string, pretty easy to set the new state. You have to call the function &lt;code&gt;setPassword&lt;/code&gt; and pass the new value. That's it.&lt;/p&gt;

&lt;p&gt;Now, this is running as we want. Click on the &lt;code&gt;Generate password&lt;/code&gt; button, and this works like magic!&lt;/p&gt;

&lt;h2&gt;
  
  
  Add a popup message for user (react-toastify)
&lt;/h2&gt;

&lt;p&gt;But we are missing one piece of the puzzle so far! We need to create a message for users to understand the password copied to their clipboards. Let's use a package for this. You can use this for any production project. We are going to use &lt;code&gt;react-toastify&lt;/code&gt; to add this. Steps for adding&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;install &lt;code&gt;react-toastify&lt;/code&gt; using &lt;code&gt;npm i react-toastify&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;import the &lt;code&gt;react-toastify&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;import usual style of &lt;code&gt;react-toastify&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Fire function from &lt;code&gt;react-toastify&lt;/code&gt; when needed&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;react-toastify&lt;/code&gt; container in div somewhere&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start with the first step -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ToastContainer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-toastify&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-toastify/dist/ReactToastify.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Importing done, let's add the function call and container inside the component. Finally, it looks like -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ToastContainer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-toastify&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-toastify/dist/ReactToastify.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPassword&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;**********************&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;generatePassword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;randomPassword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nf"&gt;setPassword&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;randomPassword&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// copy the password to the clipboard &amp;amp; fire toast message&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clipboard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;randomPassword&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Password copied to your clipboard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;background&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Generate&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;random&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wrapper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;generate-password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;generatePassword&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Generate&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* adding toast container so that we can showcase the message */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ToastContainer&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations! You've completed the first level of learning react. The project is done; time to check it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Result
&lt;/h2&gt;

&lt;p&gt;To run the project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It'll show up in &lt;code&gt;http://localhost:3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bq8sabrtpomj72rchcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bq8sabrtpomj72rchcu.png" alt="Screenshot3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  All commands I've used
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app react-password-gen // creating the new project
npm i react-toastify // installing toastify package
npm start // to run server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Source Code &amp;amp; Live link
&lt;/h2&gt;

&lt;p&gt;You can find it from here - &lt;a href="https://github.com/nerdjfpb/react-password-gen" rel="noopener noreferrer"&gt;https://github.com/nerdjfpb/react-password-gen&lt;/a&gt;&lt;br&gt;
See the live link here - &lt;a href="https://nerdjfpb.github.io/react-password-gen/" rel="noopener noreferrer"&gt;https://nerdjfpb.github.io/react-password-gen/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What to do next? (Improvement)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Make it using react components (going to teach that in next blog, follow for more content)&lt;/li&gt;
&lt;li&gt;Enable a switch for dark mode&lt;/li&gt;
&lt;li&gt;Add some animations&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Want to take the project to the next level?
&lt;/h2&gt;

&lt;p&gt;Explore how I structure react code for working with a team (this will saves a ton of time) - &lt;br&gt;
&lt;a href="https://blog.nerdjfpb.com/how-to-add-eslint-prettier-and-husky-git-hook-in-react-js-2022" rel="noopener noreferrer"&gt;https://blog.nerdjfpb.com/how-to-add-eslint-prettier-and-husky-git-hook-in-react-js-2022&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  You can also create a live link for your react project (free)
&lt;/h2&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1496480073167556613-757" src="https://platform.twitter.com/embed/Tweet.html?id=1496480073167556613"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1496480073167556613-757');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1496480073167556613&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;Drop a dm on - &lt;a href="https://twitter.com/nerdjfpb" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to be part of an amazing programming community and participate in free programming events?
&lt;/h2&gt;

&lt;p&gt;Join our &lt;a href="https://discord.gg/WBvHdMCYC7" rel="noopener noreferrer"&gt;Discord server&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to hire me for your next project?
&lt;/h2&gt;

&lt;p&gt;Connect me with &lt;a href="https://www.linkedin.com/in/nerdjfpb/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to add ESlint, Prettier, and Husky (Git Hook) in React JS 2022</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Fri, 18 Feb 2022 18:55:24 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-add-eslint-prettier-and-husky-git-hook-in-react-js-2022-55me</link>
      <guid>https://dev.to/nerdjfpb/how-to-add-eslint-prettier-and-husky-git-hook-in-react-js-2022-55me</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Today we are going to make our life easier a little bit! As developers, we have to work in a team (in most cases). Different person has different styles, so it's hard to follow a specific coding pattern. Also, some people like four spaces as a tab, and some like 2. So code format also looks weird if there are no specific rules. Today we are going to fix the problem together. Let's enforce a coding style using eslint and format our code automatically using prettier!&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;There is a reason why I'm writing this blog. I learned to program from tutorials (mostly udemy ones)! I never saw anyone is showing how to add eslint/prettier anywhere. But I learned about it while working with a side project (as freelance work). Around 2020 I was getting a good amount of leads from Fiverr to work. But it was hard for me to work on the projects because I started my current full-time. So, I took the help of my friend, and honestly, the code he wrote looks bad formatted and does not properly follow any coding styles. I always used eslint &amp;amp; prettier in my vscode, so I never faced this issue about formatting &amp;amp; following coding styles. But I wasn't really interested in setup his IDE because it's not something I can force on someone. Then I learned about eslint &amp;amp; prettier more. I made a setup, which helped me gain what I was trying too hard to get. It made my life so easier. After setting up both, I never saw terrible formatting in the app, and minor issues like not using any variables are gone! This is why I'm showing this to you. Maybe it'll save a lot of time for you! If this helps, share it with a person who needs this. Let's make the dev team strong with knowledge sharing! But before that, lets jump into the next section -&lt;/p&gt;

&lt;h2&gt;
  
  
  Things I’m using
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Visual studio code&lt;/li&gt;
&lt;li&gt;nodejs&lt;/li&gt;
&lt;li&gt;create react app&lt;/li&gt;
&lt;li&gt;npm packages

&lt;ul&gt;
&lt;li&gt;eslint&lt;/li&gt;
&lt;li&gt;prettier&lt;/li&gt;
&lt;li&gt;eslint-plugin-prettier&lt;/li&gt;
&lt;li&gt;husky&lt;/li&gt;
&lt;li&gt;lint-staged&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic React app
&lt;/h2&gt;

&lt;p&gt;We'll start with a basic React app, and we'll use &lt;a href="https://create-react-app.dev/"&gt;create-react-app&lt;/a&gt; -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app your-app-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will be a react app and we're not going to change anything because this tutorial is not related to reactjs. We're going to work directly on the next step! The more straightforward step of this tutorial is prettier. So let's dive into it!&lt;/p&gt;
&lt;h2&gt;
  
  
  Prettier
&lt;/h2&gt;

&lt;p&gt;We use prettier to auto-format our code. This saves a lot of time for me. I've also installed a vscode extension, which helps me a lot. So let's install it.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i prettier -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We're using a -D for only installing it as dev dependencies. We don't need to send this into our build. Once it is installed, let's try to format our code with prettier. But to do that, we need to create a prettier config file. Because prettier doesn't know how to format our codes, let's create that file. It'll be on our root folder, and the file name will be &lt;code&gt;.prettierrc&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "trailingComma": "es5",
 "tabWidth": 2,
 "semi": false,
 "singleQuote": true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can configure a lot of things with it. &lt;a href="https://prettier.io/docs/en/configuration.html"&gt;Click here&lt;/a&gt; to find out more. But We're going with a simple configuration. I like tabWidth two spaces, and I don't like semicolons much. All will be handled using prettier now. Isn't this awesome???&lt;/p&gt;
&lt;h2&gt;
  
  
  Eslint
&lt;/h2&gt;

&lt;p&gt;Eslint helps us to enforce a coding style. You can define your own coding style. Mostly I use &lt;a href="https://github.com/airbnb/javascript/tree/master/react"&gt;airbnb style&lt;/a&gt;. So let's install it. But if you have time, read the rules from &lt;a href="https://eslint.org/docs/rules/"&gt;eslint website&lt;/a&gt; -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i eslint -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Sadly it's not going to end here. You need to create a config file for eslint. There are two ways to do it; you can do it by&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Eslint&lt;/li&gt;
&lt;li&gt;Manual&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I prefer to use Eslint and I'll show that way because it's easier. Let's start the process by typing -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./node_modules/.bin/eslint --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then it'll popup&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? How would you like to use ESLint? ...
  To check syntax only
  To check syntax and find problems
&amp;gt; To check syntax, find problems, and enforce code style
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I'll choose &lt;code&gt;To check syntax, find problems, and enforce code style&lt;/code&gt; because I want to check syntax, find problems, and enforce code style! Then it'll show -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? What type of modules does your project use? ...
&amp;gt; JavaScript modules (import/export)
  CommonJS (require/exports)
  None of these
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I'll choose &lt;code&gt;Javascript modules (import/export)&lt;/code&gt; because I want to use import/export, not the old require/exports. Select and then -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? Which framework does your project use? ...
&amp;gt; React
  Vue.js
  None of these
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Choose the framework you are using, and this is a dumb question, right? We're using this inside reactjs. Let's select that -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? Does your project use TypeScript? » No / Yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We're not using Typescript so let's click at no! Then it'll show -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? Where does your code run? ...  (Press &amp;lt;space&amp;gt; to select, &amp;lt;a&amp;gt; to toggle all, &amp;lt;i&amp;gt; to invert selection)
√ Browser
√ Node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We'll use the browser to check the results, so select and -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? How would you like to define a style for your project? ...
&amp;gt; Use a popular style guide
  Answer questions about your style
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I'll choose the &lt;code&gt;Use a popular style guide&lt;/code&gt; one. Because that's easy to install and many developers already know about it. But if you want manual styles, just go with the &lt;code&gt;Answer questions about your style&lt;/code&gt; option. Let's select it -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;? Which style guide do you want to follow? ...
&amp;gt; Airbnb: https://github.com/airbnb/javascript
  Standard: https://github.com/standard/standard
  Google: https://github.com/google/eslint-config-google
  XO: https://github.com/xojs/eslint-config-xo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There are a few style guides already. I choose &lt;code&gt;airbnb&lt;/code&gt; most of the time. Go with the one you like!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What format do you want your config file to be in? ...
&amp;gt; JavaScript
  YAML
  JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I normally just choose &lt;code&gt;JSON&lt;/code&gt; because it's the easiest to read. But you can choose whatever you like too!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Checking peerDependencies of eslint-config-airbnb@latest
Local ESLint installation not found.
The config that you've selected requires the following dependencies:

eslint-plugin-react@^7.28.0 eslint-config-airbnb@latest eslint@^7.32.0 || ^8.2.0 eslint-plugin-import@^2.25.3 eslint-plugin-jsx-a11y@^6.5.1 eslint-plugin-react-hooks@^4.3.0
? Would you like to install them now with npm? » No / Yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's install the packages now! It'll take a little bit of time. Finally, we'll see the &lt;code&gt;.eslintrc.json&lt;/code&gt; file! Have a first look at it.&lt;/p&gt;

&lt;p&gt;Our eslint setup is done, but it will not work with prettier well. We need to do some more configuration to enable both to work together!&lt;/p&gt;
&lt;h1&gt;
  
  
  Configure eslint &amp;amp; prettier together
&lt;/h1&gt;

&lt;p&gt;This section also starts with installing an npm package called &lt;code&gt;eslint-plugin-prettier&lt;/code&gt;, which will help us configure eslint and prettier together. We'll install it with -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i eslint-plugin-prettier -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We need to add this plugin inside &lt;code&gt;.eslintrc.json&lt;/code&gt; file -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "plugin:react/recommended",
        "airbnb"
    ],
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "plugins": [
        "react", "prettier"
    ],
    "rules": {
      "semi": 0,
      "comma-dangle": 0,
      "prettier/prettier": "error",
      "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I updated the last two-part - &lt;code&gt;plugins&lt;/code&gt; and &lt;code&gt;rules&lt;/code&gt;. This will help us to work prettier and eslint together. Don't worry; there is no more configuration needed for eslint and prettier.&lt;/p&gt;

&lt;p&gt;Also, let's add two scripts to our &lt;code&gt;package.json&lt;/code&gt; file. This will help us to lint files by &lt;code&gt;npm run lint&lt;/code&gt; and format our code by &lt;code&gt;npm run pretty&lt;/code&gt; -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "lint": "eslint --fix",
    "pretty": "prettier --write ."
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;One quick note: In your project, maybe some files you don't want to lint or format. So you can add them to &lt;code&gt;.eslintignore&lt;/code&gt; file -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules
public
build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For the ignore format, you can use &lt;code&gt;.prettierignore&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Ignore artifacts:
build
coverage

# Ignore all HTML files:
*.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But there is still a problem remaining. This all will work if you use an IDE with extensions like - eslint &amp;amp; prettier. Without it'll not format automatically. We can force it by using &lt;code&gt;script&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt; file. But let's find a better solution!&lt;/p&gt;
&lt;h2&gt;
  
  
  Husky
&lt;/h2&gt;

&lt;p&gt;To force our coding style &amp;amp; format, we will use git hook. So that if anyone commits any code, it runs some linting and check if there is any issue with it. For this, we're going to use &lt;code&gt;husky&lt;/code&gt; and &lt;code&gt;lint-staged&lt;/code&gt; -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i husky lint-staged -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will just install the package. But for using &lt;code&gt;lint-staged&lt;/code&gt; we need to edit our &lt;code&gt;package.json&lt;/code&gt; file. Let's add some lines -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "lint-staged": {
  "**/*.{js,jsx}": [
    "npm run lint",
    "prettier --write"
  ]
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;With these four lines, we are just linting and formatting our code. But it's not called from anywhere now. So we need to call it from somewhere. But before that, we need to install husky properly to run it -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx husky-init &amp;amp;&amp;amp; npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will create a folder called &lt;code&gt;.husky&lt;/code&gt; and inside it a file called &lt;code&gt;pre-commit&lt;/code&gt; which will run &lt;code&gt;npm test&lt;/code&gt; before committing. But for the current project, we don't want to run the &lt;code&gt;npm test&lt;/code&gt;, so we are going to change it into -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# npm test
npx lint-staged
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now we can try committing in git, and it'll show us if there is an error! Now we are finally ready to test our project!&lt;/p&gt;
&lt;h2&gt;
  
  
  Result and Testing
&lt;/h2&gt;

&lt;p&gt;We'll not explore the git today with this tutorial. Because git is a big topic and that needs another blog. You can quickly do a crash course on the git. Then came back here to see what I was doing from this point. First, I'll change a little bit on the &lt;code&gt;app.js&lt;/code&gt; file; going to add an extra line that we don't need (Just to showcase what we have done so far)&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import logo from './logo.svg'
import './App.css'

function App() {
  const tempVar = 5

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;header className="App-header"&amp;gt;
        &amp;lt;img src={logo} className="App-logo" alt="logo" /&amp;gt;
        &amp;lt;p&amp;gt;
          Edit
          &amp;lt;code&amp;gt;src/App.js&amp;lt;/code&amp;gt;
          and save to reload.
        &amp;lt;/p&amp;gt;
        &amp;lt;a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        &amp;gt;
          Learn React
        &amp;lt;/a&amp;gt;
      &amp;lt;/header&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default App
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I just added the &lt;code&gt;const tempVar = 5&lt;/code&gt; after the function, and let's try to commit this into the github repo. I'm using&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git commit -m "Initial Commit"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now I'm getting an error.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 10 files
[STARTED] **/*.{js,jsx} — 2 files
[STARTED] npm run lint
[FAILED] npm run lint [FAILED]
[FAILED] npm run lint [FAILED]
[SUCCESS] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[SUCCESS] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[SUCCESS] Cleaning up temporary files...

✖ npm run lint:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-eslint-prettier@0.1.0 lint: `eslint --fix "C:/Users/demo/Desktop/nerdworks/Blogs Examples/react-eslint-prettier/src/App.js" "C:/Users/demo/Desktop/nerdworks/Blogs Examples/react-eslint-prettier/src/index.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-eslint-prettier@0.1.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\demo\AppData\Roaming\npm-cache\_logs\2022-02-18T18_07_55_543Z-debug.log

&amp;gt; react-eslint-prettier@0.1.0 lint C:\Users\demo\Desktop\nerdworks\Blogs Examples\react-eslint-prettier
&amp;gt; eslint --fix "C:/Users/demo/Desktop/nerdworks/Blogs Examples/react-eslint-prettier/src/App.js" "C:/Users/demo/Desktop/nerdworks/Blogs Examples/react-eslint-prettier/src/index.js"


C:\Users\demo\Desktop\nerdworks\Blogs Examples\react-eslint-prettier\src\App.js
  6:9  error  'tempVar' is assigned a value but never used  no-unused-vars

✖ 1 problem (1 error, 0 warnings)

husky - pre-commit hook exited with code 1 (error)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Maybe it'll look overwhelming at first. But if you read from last, you'll understand what we are doing here. Here the problem is showing on.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6:9  error  'tempVar' is assigned a value but never used  no-unused-vars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;So that tempVar we created is creating an issue. Why? Because we are not using this variable. So just delete this and try to commit again. This time it'll just work fine -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 10 files
[STARTED] **/*.{js,jsx} — 2 files
[STARTED] npm run lint
[SUCCESS] npm run lint
[STARTED] prettier --write
[SUCCESS] prettier --write
[SUCCESS] **/*.{js,jsx} — 2 files
[SUCCESS] package.json — 10 files
[SUCCESS] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SUCCESS] Applying modifications from tasks...
[STARTED] Cleaning up temporary files...
[SUCCESS] Cleaning up temporary files...
[master 205b14e] Initial Commit
13 files changed, 449 insertions(+), 119 deletions(-)
 create mode 100644 .eslintignore
 create mode 100644 .eslintrc.json
 create mode 100644 .husky/pre-commit
 create mode 100644 .prettierignore
 create mode 100644 .prettierrc
 rewrite README.md (99%)
 delete mode 100644 src/App.test.js
 rewrite src/index.js (78%)
 delete mode 100644 src/reportWebVitals.js
 delete mode 100644 src/setupTests.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This way, all the files will be used eslint &amp;amp; prettier before going to our GitHub repository!&lt;/p&gt;
&lt;h2&gt;
  
  
  Outro
&lt;/h2&gt;

&lt;p&gt;I hope that this one helps you to work with your team in a better manner. That was the primary goal of this blog! Also, we can easily see the Eslint error and prettier automatically using vscode extensions. I also use some other extensions; you can check it here -&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CYMFzUql6Ra/embed/captioned"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;



&lt;h2&gt;
  
  
  Github Repo
&lt;/h2&gt;

&lt;p&gt;You can find it from here - &lt;a href="https://github.com/nerdjfpb/react-eslint-prettier"&gt;https://github.com/nerdjfpb/react-eslint-prettier&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;Drop a dm on - &lt;a href="https://twitter.com/nerdjfpb"&gt;twitter&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to be part of an amazing programming community and participate in free programming events?
&lt;/h2&gt;

&lt;p&gt;Join our &lt;a href="https://discord.gg/WBvHdMCYC7"&gt;Discord server&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to hire me for your next project?
&lt;/h2&gt;

&lt;p&gt;Connect me with &lt;a href="https://www.linkedin.com/in/nerdjfpb/"&gt;linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How To Build Simple CRUD RESTful API With NodeJS, ExpressJS And MongoDB in 2022</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Fri, 04 Feb 2022 20:08:06 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-build-simple-crud-restful-api-with-nodejs-expressjs-and-mongodb-in-2022-4756</link>
      <guid>https://dev.to/nerdjfpb/how-to-build-simple-crud-restful-api-with-nodejs-expressjs-and-mongodb-in-2022-4756</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Node js is a popular backend nowadays! It's fast and easy to write code. If you already know javascript, it can be easy to write node js. So we're going to explore express js today with MongoDB for the database. We'll create the rest API endpoints and implement CRUD operation for the to-do list. The example is quite basic, but we're going to make a good project structure so that you can follow it for your other projects too! Let's dive in -&lt;/p&gt;

&lt;h2&gt;
  
  
  Things I'm using
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Vscode&lt;/strong&gt;: I've used the vscode for the whole development!&lt;br&gt;
&lt;strong&gt;Node js&lt;/strong&gt;: I've used node js v14.8.0&lt;br&gt;
&lt;strong&gt;MongoDB compass&lt;/strong&gt;: I've used MongoDB v1.30.1 to see all changes in MongoDB graphically&lt;br&gt;
&lt;strong&gt;Postman&lt;/strong&gt;: We'll use this one to test all our api's&lt;br&gt;
&lt;strong&gt;Packages&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;babel: For transpile the javascript into an older version&lt;/li&gt;
&lt;li&gt;cors: For the CORS setting&lt;/li&gt;
&lt;li&gt;dotenv: For reading the environment variables&lt;/li&gt;
&lt;li&gt;eslint: For enforcing a coding style&lt;/li&gt;
&lt;li&gt;express js: The node framework&lt;/li&gt;
&lt;li&gt;express-rate-limit: For limiting the API endpoint calls&lt;/li&gt;
&lt;li&gt;husky: For git pre-commit to hook for implementing eslint &amp;amp; prettier before committing&lt;/li&gt;
&lt;li&gt;joi: Used to validate the user inputs&lt;/li&gt;
&lt;li&gt;mongoose: MongoDB ORM for working with MongoDB&lt;/li&gt;
&lt;li&gt;morgan: For showing API endpoint details&lt;/li&gt;
&lt;li&gt;nodemon: For running the server, when we change a file&lt;/li&gt;
&lt;li&gt;prettier: For formatting the code&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Basic Project Setup
&lt;/h3&gt;

&lt;p&gt;We'll start with &lt;code&gt;npm init -y&lt;/code&gt; on the folder to initialize the node and create the &lt;code&gt;package.json&lt;/code&gt; file. You can edit the package.json file as you want! Now create an src folder to write all our code in the folder. We'll also make an &lt;code&gt;index.js&lt;/code&gt; file as a starter.&lt;/p&gt;

&lt;p&gt;Setup the Express JS with babel&lt;br&gt;
If we usually set up the nodejs with &lt;code&gt;npm init -y&lt;/code&gt;, then we can't use the latest features of javascript! To solve this problem, we are going to use babel. Babel is a compiler for javascript; it complies with the new versions of javascript to older javascript. If we active babel, we can use async-await, which will transfer into earlier javascript!&lt;/p&gt;

&lt;p&gt;To set up the babel, we need to install -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i @babel/cli @babel/core @babel/node @babel/preset-env -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and also, we need to add a file called .babelrc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "presets": [
 "@babel/preset-env"
 ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to adjust the &lt;code&gt;package.json&lt;/code&gt; file to work correctly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"start": "node dist/index.js",
"dev": "nodemon --exec babel-node src/index.js",
"build": "babel src -d dist",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will complete the babel set up, and you can run it by using &lt;code&gt;npm run dev&lt;/code&gt; if you want a production version, then use &lt;code&gt;npm run build&lt;/code&gt; first and then try &lt;code&gt;npm start&lt;/code&gt; that will start the application!&lt;/p&gt;

&lt;h3&gt;
  
  
  Improving coding styles &amp;amp; formatting
&lt;/h3&gt;

&lt;p&gt;This part is only needed if you are interested in maintaining good structure and rules throughout the codebase. This will require the eslint and prettier. Eslint will enforce a coding style, so every developer follows specific rules. Prettier will follow the code format automatically! Eslint comes with vscode! So you don't need to install eslint on your vscode. But you need to install the prettier on your codebase because it is necessary for code styles. So how to install them? Let's do it together by installing -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install eslint eslint-config-prettier prettier -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's set up the prettier first, which is pretty straightforward. We've to create a file called .prettierrc, and we need to put&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "trailingComma": "es5",
 "tabWidth": 2,
 "semi": false,
 "singleQuote": true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is all needed for the prettier now; let's set up the Eslint. For Eslint, setup starts with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./node_modules/.bin/eslint --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will pop up some questions. Now select the one based on your interest. For this project, we choose&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To check syntax, find problems, and enforce code style&lt;/li&gt;
&lt;li&gt;CommonJS (require/exports)&lt;/li&gt;
&lt;li&gt;None of these&lt;/li&gt;
&lt;li&gt;No&lt;/li&gt;
&lt;li&gt;Node&lt;/li&gt;
&lt;li&gt;Use a popular style guide&lt;/li&gt;
&lt;li&gt;JSON&lt;/li&gt;
&lt;li&gt;Yes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now it'll install some new packages and create .eslintrc.json file! Now we have to edit a little bit here -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"extends": ["airbnb-base","prettier"],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll add the prettier here, and we are pretty done. If your vscode has all the extensions already, if you write any wrong code, then you'll see the errors.&lt;/p&gt;

&lt;p&gt;If someone doesn't want to use the vscode extensions, they can check the error by running &lt;code&gt;npm run lint&lt;/code&gt;. But it'll fail because we didn't add any script like this. So go to the &lt;code&gt;package.json&lt;/code&gt; file and add -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"lint": "eslint --fix"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Improving git experience with husky
&lt;/h3&gt;

&lt;p&gt;Our codebase has some rules and formatting ways. But still, it's not going to happen if someone doesn't have those extensions or doesn't care about the errors. Also, many devs work from different IDE; you can't force them to use the same one. So we will play with the git hook a little bit to solve the problem. So whenever anyone tries to commit, we will check the eslint, and then we will format the file with prettier. So how to do it?&lt;/p&gt;

&lt;p&gt;We can do it using husky &amp;amp; lint-staged, and we will work on that right now. Let's install husky and lint-staged&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i husky lint-staged -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to improve the package.json file. Add some extra lines on the last part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "lint-staged": {
    "**/*.{js,jsx}": [
        "npm run lint",
        "prettier --write"
    ]
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to enable the git hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx husky install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let's add a git hook which is going to help us to do the lint-staged before committing the changes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx husky add .husky/pre-commit "npm test"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you'll see a .husky folder on the root level with a file inside &lt;code&gt;pre-commit&lt;/code&gt;, and let's modify it a little bit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# npm test
npx lint-staged
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it'll work like magic. Try to commit your changes and see it's doing something before committing, and this way, you can easily enforce something before committing!&lt;/p&gt;

&lt;h3&gt;
  
  
  Improving security
&lt;/h3&gt;

&lt;p&gt;Now our server is quite ready. Let's jump into the &lt;code&gt;index.js&lt;/code&gt; file to start our work. But before that, let's improve the security a little bit. We will use environment variables because we're not going to expose it directly out on our repo! For this, we will use the &lt;code&gt;dotenv&lt;/code&gt; npm package. It's super easy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import'dotenv/config'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The upper line will give us the power to access any value from the .env file (from root)! Check .env-example to get an idea of what I've inside the .env file. It's your credential/secret data, so never upload it to the public git repo! To access any variable, use -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;process.env.VARIBALE_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's do some basic stuff.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Express from 'express'

const app = Express()

const port = process.env.PORT || 3000
app.listen(port, () =&amp;gt; console.log(`listening on port ${port}`))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's add some middlewares here. The first one will be cors because it enables you to do the CORS settings! Also, add &lt;code&gt;helmet&lt;/code&gt; middleware. It helps you secure your Express apps by setting various HTTP headers! The code will look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Cors from 'cors'
import Helmet from 'helmet'

app.use(Cors())
app.use(Helmet())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we are building the API, there can be some DDoS attack or potential hacker attack, or maybe something is broken, and it keeps calling the API like thousand times in a min. We don't want that. So let's add a limit -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import RateLimit from 'express-rate-limit'

const limiter = RateLimit({
  windowMs: 15 * 60 * 1000,
  max: 100,
  standardHeaders: true,
  legacyHeaders: false,
})

app.use(limiter)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Are we done? Sadly no. We are going to make a slight improvement on the server! We'll check details on every API call in our console.log, so we're going to add a logging package called &lt;code&gt;morgan&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Morgan from 'morgan'

app.use(Morgan('tiny'))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The upper two lines will help us see the API endpoints details on our console.&lt;/p&gt;

&lt;p&gt;Finally, for the JSON inputs from user, add the last middleware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.use(Express.json())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It parses incoming requests with JSON payloads and is based on body-parser!&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to MongoDB
&lt;/h2&gt;

&lt;p&gt;Connecting to MongoDB is pretty straightforward. First, we are going to install the mongoose package. Because it's better than just using MongoDB, it's an ORM and comes with lots of benefits already. So how to connect a DB with it?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Mongoose from 'mongoose'

Mongoose.connect('mongodb://localhost/demotodo')
 .then(() =&amp;gt; console.log('Connected to MongoDB...'))
.catch((err)=&amp;gt;console.log(`Could not connect to MongoDB...${err}`))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See, this is so easy, right? '&lt;/p&gt;

&lt;p&gt;Now, let's start writing the API endpoints.&lt;/p&gt;

&lt;p&gt;Let's create a post API endpoint first so that we can add some values inside the database &lt;code&gt;demotodo&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  REST API endpoints
&lt;/h3&gt;

&lt;p&gt;We're going to create five endpoints. Let's look at the URLs first -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/app/v1 -&amp;gt; Post -&amp;gt; add a data to database
/api/v1 -&amp;gt; Get -&amp;gt; get all the data from database
/app/v1/id -&amp;gt; Get -&amp;gt; get a single item data by id from database
/app/v1 -&amp;gt; Delete -&amp;gt; delete a data from database
/app/v1 -&amp;gt; Put -&amp;gt; update a data from database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll start with the POST method. But before that, let's make our code a little better. We'll create a folder called &lt;code&gt;routes&lt;/code&gt; and &lt;code&gt;model&lt;/code&gt;. In the model folder, we'll put the MongoDB database model. In the routes folder, we'll post different routes. You can also create a &lt;code&gt;controller&lt;/code&gt; folder to write the controller, called from routes. But for simplicity, I'll go with one single file in routes &amp;amp; model. Let's create a &lt;code&gt;todo.js&lt;/code&gt; file in the model &amp;amp; route both folders.&lt;/p&gt;

&lt;p&gt;Now lets a go-to model first to create the model. We'll call the mongoose package and make the data structure here. We're going simple. We'll create a &lt;code&gt;title&lt;/code&gt;(text) &amp;amp; &lt;code&gt;completed&lt;/code&gt; (bool) for the schema, and when we add data from here, it'll always add a unique id by mongo. Let's do this -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Mongoose from 'mongoose'

const todoSchema = new Mongoose.Schema({
  title: {
    type: String,
    required: true,
    trim: true,
    minlength: 5,
    maxlength: 255,
  },
  completed: {
    type: Boolean,
    default: false,
  },
})

export default TodoModel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upper lines will create the model. But we also need to do validation when someone sends us data. We'll put the validation function here because it'll be closer and easier to maintain. Let's add the &lt;code&gt;joi&lt;/code&gt; package to write the validation function -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Joi from 'joi'

const TodoModel = Mongoose.model('Todo', todoSchema)

const JoiSchema = Joi.object({
  title: Joi.string().min(5).max(255).required(),
  completed: Joi.boolean(),
})

export const validateTodo = (todo) =&amp;gt; JoiSchema.validate(todo)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll use this both export from our routes file. Let's do the POST method right now!&lt;/p&gt;

&lt;h3&gt;
  
  
  POST
&lt;/h3&gt;

&lt;p&gt;As a starter of &lt;code&gt;routes/todo.js&lt;/code&gt; we'll call the libraries and model with validations -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express'
import Mongoose from 'mongoose'
import Todo, { validateTodo } from '../model/todo'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now write the router -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const router = express.Router()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's time to write the post route to add data from the postman! We'll follow some steps to write this part of the code -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is there an error with the validate function from the &lt;code&gt;model/todo.js&lt;/code&gt; file? If error then send a response with an error&lt;/li&gt;
&lt;li&gt;If there is no error, then create data using the mongoose model&lt;/li&gt;
&lt;li&gt;Save it &amp;amp; send a reply to the user
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// insert a new data in todo
router.post('/', async (req, res) =&amp;gt; {
  // validate using Joi, with factoring function
  const { error } = validateTodo(req.body)

  // if have any error then return bad request with error else just add the new one
  if (error) {
    return res.status(400).json({
      success: false,
      data: [],
      message: error?.details[0]?.message,
    })
  }

  let todo = new Todo({
    title: req?.body?.title,
    completed: false,
  })

  todo = await todo.save()

  return res.json({
    success: true,
    data: todo,
    message: 'New todo adding successful!',
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's test it from the postman! Start the app with &lt;code&gt;npm run dev&lt;/code&gt; and go to URL &lt;code&gt;localhost:3000/api/v1/&lt;/code&gt; -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zso9qwwmw3uf1l94ty2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zso9qwwmw3uf1l94ty2.png" alt="post method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GET
&lt;/h3&gt;

&lt;p&gt;Let's find out the steps we need to get all the data from mongodb&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find out all the data using find()&lt;/li&gt;
&lt;li&gt;Send as response
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Get request for getting all todo data
router.get('/', async (_req, res) =&amp;gt; {
  // sending all data to response
  const todos = await Todo.find()

  return res.json({
    success: true,
    data: todos,
    message: 'Request successful!',
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's pretty easy! Right? Start the app with &lt;code&gt;npm run dev&lt;/code&gt; and go to URL &lt;code&gt;localhost:3000/api/v1/&lt;/code&gt; -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F844xdss2dvf5mxsj8qay.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F844xdss2dvf5mxsj8qay.png" alt="Get method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GET A SINGLE
&lt;/h3&gt;

&lt;p&gt;Let's find out the steps we need to get a single data from mongodb&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check if the given id is a mongodb valid id. If not, send a error response to user&lt;/li&gt;
&lt;li&gt;Otherwise, try to get the data using findById(givenID)&lt;/li&gt;
&lt;li&gt;Send response based on the data we got
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Get the data about a single todo
router.get('/:id', async (req, res) =&amp;gt; {
  if (!Mongoose.Types.ObjectId.isValid(req.params.id))
    return res.status(404).json({
      success: false,
      data: [],
      message: 'It is not a valid mongodb id',
    })

  // search using id In mongodb with mongoose
  const todo = await Todo.findById(req.params.id)

  // checking if todo not found then 404 request
  if (!todo)
    return res.status(404).json(
      res.json({
        success: false,
        data: [],
        message: 'There is no data found related to this id!',
      })
    )

  // if found then send the response
  return res.json({
    success: true,
    data: todo,
    message: 'Finding successful!',
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's pretty easy! Right? Start the app with &lt;code&gt;npm run dev&lt;/code&gt; and go to URL &lt;code&gt;localhost:3000/api/v1/id&lt;/code&gt; -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm5f5agcd678zda8eps2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm5f5agcd678zda8eps2.png" alt="get single"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  PUT
&lt;/h3&gt;

&lt;p&gt;Let's find out the steps we need to update the data in MongoDB&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, validate the data user is sending to API; if there is inaccurate data, just send an error response to the user!&lt;/li&gt;
&lt;li&gt;Otherwise, try to update data by finding id first. Use findByIdAnUpdate() method to do it with giving the new data&lt;/li&gt;
&lt;li&gt;If there is data, then it'll be blank, and the response will error; otherwise, send the success response!
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// update an existing todo
router.put('/:id', async (req, res) =&amp;gt; {
  // Validating the user input
  const { error } = validateTodo(req.body)

  if (error) {
    return res.status(400).json({
      success: false,
      data: [],
      message: error?.details[0]?.message,
    })
  }

  // find Id and updated it by mongoose
  const todo = await Todo.findByIdAndUpdate(
    req.params.id,
    { title: req?.body?.title, completed: req?.body?.completed },
    {
      new: true,
    }
  )

  // if todo is not available then error or else new updated data send to user
  if (!todo)
    return res.status(404).json({
      success: false,
      data: [],
      message: 'There is no data found related to this id!',
    })

  return res.json({
    success: true,
    data: todo,
    message: 'Update successful!',
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's pretty easy! Right? Start the app with &lt;code&gt;npm run dev&lt;/code&gt; and go to URL &lt;code&gt;localhost:3000/api/v1/id&lt;/code&gt; -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lxm9g6kxj9d4jy67105.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lxm9g6kxj9d4jy67105.png" alt="put method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  DELETE
&lt;/h3&gt;

&lt;p&gt;Let's find out the steps we need to delete data from MongoDB&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We'll try to delete once we get the id by findByIdAndRemove()&lt;/li&gt;
&lt;li&gt;Send response based on the result
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// delete a todo
router.delete('/:id', async (req, res) =&amp;gt; {
  // find an delete the data using moongoose &amp;amp; mongodb
  const deletedTodo = await Todo.findByIdAndRemove(req?.params?.id)

  // checking if todo not found then 404 request &amp;amp; if found then send the response
  if (!deletedTodo)
    return res.status(404).json({
      success: false,
      data: [],
      message: 'There is no data found related to this id!',
    })

  // finally response send with deleted data
  return res.json({
    success: true,
    data: deletedTodo,
    message: 'Delete successful!',
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's pretty easy! Right? Start the app with &lt;code&gt;npm run dev&lt;/code&gt; and go to URL &lt;code&gt;localhost:3000/api/v1/id&lt;/code&gt; -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmefhqx5k4n8gwaksbz82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmefhqx5k4n8gwaksbz82.png" alt="Delete method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try to delete the same id again! Let's see what happens -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9lvlk7idpqyasr1m1wb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9lvlk7idpqyasr1m1wb.png" alt="Delete single"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final words
&lt;/h3&gt;

&lt;p&gt;I've tried to explain everything as I think. But there is a lot of improvement we can make. I didn't add a try-catch block because this blog will be long after that. But you should add that. If you want to see the code. Please check out - &lt;a href="https://github.com/nerdjfpb/expressjs-rest-api-with-mongodb" rel="noopener noreferrer"&gt;https://github.com/nerdjfpb/expressjs-rest-api-with-mongodb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;I’ve started a programming community on discord. Click to join &lt;a href="https://discord.gg/WBvHdMCYC7" rel="noopener noreferrer"&gt;Discord Channel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Originally it published on &lt;a href="https://blog.nerdjfpb.com/how-to-build-simple-crud-restful-api-with-nodejs-expressjs-and-mongodb-in-2022/" rel="noopener noreferrer"&gt;nerdjfpbblog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can connect with me in &lt;a href="https://twitter.com/nerdjfpb" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; or &lt;a href="https://www.linkedin.com/in/nerdjfpb/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt; or &lt;a href="https://www.instagram.com/nerd_jfpb/" rel="noopener noreferrer"&gt;instagram&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Get a Remote Job in 2022?</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Thu, 27 Jan 2022 15:13:10 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-get-a-remote-job-in-2022-9o4</link>
      <guid>https://dev.to/nerdjfpb/how-to-get-a-remote-job-in-2022-9o4</guid>
      <description>&lt;p&gt;Finding a job is hard. Suppose you are looking for a remote position. In office-based employment, you can quickly build up a team and talk with the team. But in remote jobs, things are a bit different. Hard to build a good bonding from online chat (most cases; not for everyone). But let’s take a step back from thinking about how to do the job and focus on getting a job. If you are reading this blog, I assume you already have some skills and are ready to find a job. I’m going to share how you can find a remote job!&lt;/p&gt;

&lt;h1&gt;
  
  
  LinkedIn
&lt;/h1&gt;

&lt;p&gt;If you don’t have a LinkedIn profile, please create it right away. It works as an online resume and is super helpful to grab a job. Get a professional picture as a profile pic and put a decent cover. Also, write everything honestly, don’t add something you don’t know because the job can come for that skill. Here is an example of a good LinkedIn profile – &lt;a href="https://www.linkedin.com/in/brianalkass/"&gt;https://www.linkedin.com/in/brianalkass/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FekXALS7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9x28mlzxzmk70rbx76g0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FekXALS7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9x28mlzxzmk70rbx76g0.png" alt="good linkedin example" width="816" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from one single look, you can find out what he can do, right? Recruiters will just look for a few seconds on your profile to make it as good as you can so that they get hooked with it.&lt;/p&gt;

&lt;p&gt;To make a good profile, please add &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Experiences&lt;/li&gt;
&lt;li&gt;Educations&lt;/li&gt;
&lt;li&gt;License and certification (if any)&lt;/li&gt;
&lt;li&gt;Skills&lt;/li&gt;
&lt;li&gt;Recommendations (from others)
Also, try to post what you are learning/developing from time to time. Posting once a day or one post in two days can work well. Just try to network as much as you can.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you have a good LinkedIn profile, let’s start searching the jobs. There is a job tab on the navbar. You can just click there and look for the jobs it’s recommended. It’ll mostly recommend local jobs. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cMWWv5oA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6p634b6sc06uchqd03am.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cMWWv5oA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6p634b6sc06uchqd03am.png" alt="local jobs" width="880" height="603"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you also can search for your job and put the location “Remote”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JHhOhvTd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/znnbhoqh8tld0qit6m1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JHhOhvTd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/znnbhoqh8tld0qit6m1a.png" alt="Searching remote" width="880" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are looking for a specific role, you can also search for your position here. So this is the easiest way to apply for a job using LinkedIn. But I’m going to help you to learn something more.&lt;/p&gt;

&lt;p&gt;Go to the homepage, search “Remote reactjs” and select posts; the date posted will be 24 hours. Finally, try sort by latest this will give you the post people did in the last 24 hours about the remote reactjs keyword. So here you can find someone who is hiring remote people. This way, you connect with a human instead of mass applying on a job post (which companies can easily ignore). Here is the example –&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fS_nHDzD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/myqnut2ga2i49gd3s64e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fS_nHDzD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/myqnut2ga2i49gd3s64e.png" alt="searching by keyword to find jobs" width="880" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this will help you to get some remote jobs from LinkedIn. But if it doesn’t work in your case. Let’s go to step 2.&lt;/p&gt;

&lt;h1&gt;
  
  
  Discord/Slack Communities
&lt;/h1&gt;

&lt;p&gt;Every programming language or framework nowadays has a community. I assume some people are not technical; maybe who is reading this blog. Then you can join some communities where you can get some insight about your position &amp;amp; job board maybe. I’m going to give an example related to react js again. React js has an amazing discord community!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hlitppSf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jty15kc750bq84m38v6c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hlitppSf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jty15kc750bq84m38v6c.png" alt="reactiflux community" width="880" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can easily find a job board here, which posts many jobs related to react js! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6hzsUS18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5olp3b8cvgpotnzlo9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6hzsUS18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5olp3b8cvgpotnzlo9j.png" alt="reactiflux community job board" width="880" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, if you join in other communities as I joined in –&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--osVBcLoc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gt8kuzh2oa9k7e0r3yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--osVBcLoc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gt8kuzh2oa9k7e0r3yb.png" alt="Commit your code" width="880" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RL7j9tO9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs8126iaorkjjxnr9v7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RL7j9tO9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs8126iaorkjjxnr9v7m.png" alt="Tailwind css" width="880" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you can also join some slack like this –&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sd3wveQQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wilt174ub2djl8ly94yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sd3wveQQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wilt174ub2djl8ly94yy.png" alt="Slack group" width="880" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Joining communities can help you get a job quickly. So worth trying! If you don’t like this idea, I have got more options for you! Read more to find out!&lt;/p&gt;

&lt;h1&gt;
  
  
  Remote jobs sites
&lt;/h1&gt;

&lt;p&gt;You can follow many remote jobs sites every day to find new jobs. Here are the popular ones I usually suggest using – &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We work remotely – &lt;a href="https://weworkremotely.com/"&gt;https://weworkremotely.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Remote io – &lt;a href="https://www.remote.io/"&gt;https://www.remote.io/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Remote ok – &lt;a href="https://remoteok.com/"&gt;https://remoteok.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Angellist – &lt;a href="https://angel.co/"&gt;https://angel.co/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;4 day week – &lt;a href="https://4dayweek.io/"&gt;https://4dayweek.io/&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Hacker news jobs – &lt;a href="https://news.ycombinator.com/jobs"&gt;https://news.ycombinator.com/jobs&lt;/a&gt;
There are tons of websites/newsletters you can follow to get job information. But I feel good with the list I gave. Angellist is mainly about the startup, so go for it first if you like to work on a startup. 4/day week focuses on the jobs where you work four days a week. Hacker news jobs are mostly startup jobs. So I hope this will help you to get jobs from here. &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Twitter
&lt;/h1&gt;

&lt;p&gt;If you are still here, then it means that you want to do more. The good thing is I’ve more for you! This step is looking the jobs on Twitter. I usually follow the people who are related to my tech stack. In this way, I can see if someone is hiring people about my stack. Also, some people hire using a tweet. So you can get hired by a tweet. I got my current job from a tweet. So I can say it’s possible. Also, here you connect with a human, which is always better. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9eIZmuwj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chzgq8kkwibruwfrgtzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9eIZmuwj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chzgq8kkwibruwfrgtzy.png" alt="Image description" width="583" height="675"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reddit&lt;/strong&gt; also has many job boards; you can check those out for getting some remote jobs info.&lt;/p&gt;

&lt;p&gt;I hope this whole blog will help you get the position you want. I am hoping for the best!&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;If you have a question. Please reach out to me in – &lt;a href="https://www.instagram.com/nerd_jfpb/"&gt;instagram&lt;/a&gt;, &lt;a href="https://twitter.com/nerdjfpb"&gt;twitter&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/nerdjfpb/"&gt;linkedin&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m building a developer community. If you want to join then –&lt;/p&gt;

&lt;p&gt;&lt;a href="https://discord.gg/WBvHdMCYC7"&gt;https://discord.gg/WBvHdMCYC7&lt;/a&gt;&lt;/p&gt;

</description>
      <category>remote</category>
      <category>job</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>This Is The Most Productive Working From Home Routine I’ve ever made</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Fri, 21 Jan 2022 13:13:16 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/this-is-the-most-productive-working-from-home-routine-ive-ever-made-51j0</link>
      <guid>https://dev.to/nerdjfpb/this-is-the-most-productive-working-from-home-routine-ive-ever-made-51j0</guid>
      <description>&lt;p&gt;My work routine is a mess. Usually, people suggest working in the morning to do a lot of stuff. Many famous people start their day around 3/4/5 AM, and here me! A non-famous nerd starting his day around 2-3 pm, which can be super unhealthy (don’t try this at home).&lt;/p&gt;

&lt;p&gt;I had no other choice; I am not too fond of local jobs, and most of the remote jobs are from the US side. So I had to work on US time. Currently, I start working at 8 pm (local time) EST at 9 am and end my work around 4 am (where famous people woke up). So currently, I’m a night owl.&lt;/p&gt;

&lt;p&gt;Nighttime can be productive, like morning, but it is also a time where we like to procrastinate! The same thing happens to me; some days, I keep watching youtube during work hours for nothing. I’m kind of just wasting time doing nothing. Maybe making up a routine for my work time would help me. So I started to follow a new pattern that will help me work properly with focus.&lt;/p&gt;

&lt;p&gt;If you don’t have a routine yet, stop reading the blog more. Make a routine at least, then come back and read the rest. Finally, improve your routine. Routine is not something you just make once; first, you need to make a demo one, then you’ll try that in your life. If it goes well, then you need to fix that and improve the parts that need to improve! Because a good routine will lead you to a good habit, which will guide you into a success!&lt;/p&gt;

&lt;p&gt;Let’s see what I planned for my routine! I usually work around 10 hours per day (8 hours office, 2hours for side projects, part-time, or some other stuff). I work about six days per week (5 days for the office and one day for my side work), and I take one day as a complete break. Also, after a few weeks, I take two whole days off! Also, if I get any off days through the week for different reasons, I just enjoy the day! Working is good, but too much work leads to burnout, and fixing the burnout is a more difficult puzzle that I don’t want to solve!&lt;/p&gt;

&lt;p&gt;My routine is well-detailed and well-organized. So my local time 8 pm-4 am I work, I start my working day from 6 pm (sunset around 5.15 pm now). First two hours, I usually break into my two 45mins focus times and 15 mins break after the session! The first hour I spend learning something, I am a tutorial learning person, so I start with a course (any course). But if I follow the same routine for the next six days, it is pretty dull. So I try to grab two courses at a time, and I swap them. Like –&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fitfdww6i3exh4jwmh4gj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fitfdww6i3exh4jwmh4gj.png" alt="Routine part one"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also see that I’m swapping my time with part-time and content creation from the table. In this way, I don’t get bored every day. For 45mins, I do a focus session because, after that, I’m getting a 15mins break (where I try to get out of the seat and take some food/water, but most of the time, I just browse social media).&lt;/p&gt;

&lt;p&gt;I hope you got an idea of how I am writing this blog! I wrote it somewhere in my content creation slot! Now I’ll reveal how I make a routine for my office work! Let’s talk in detail about it!&lt;/p&gt;

&lt;p&gt;Typically we have a daily standup after half-hour of office time start. So every day, I try to start my office around the exact time, so I got some time to check, write and think about the day. First, I go to Jira and check if any ticket needs any status change or any new ticket assigned to me. Also, I try to recap what I did yesterday because, in our daily standup, we talk about what we did yesterday and what we are planning to do today! So in this way. The first half-hour, I plan what I need to do, what questions I’ve to ask my seniors &amp;amp; what I did yesterday!&lt;/p&gt;

&lt;p&gt;Usually, daily standup takes around 15-30mins, sometimes more than that. But let’s talk about a normal situation. So my first office hour ends with the meeting most of the time. I try to take a break of 5-10mins here. Before starting the next hour.&lt;/p&gt;

&lt;p&gt;From this hour I keep focusing more &amp;amp; more about work. I try to do three 45 mins sessions of work with 15mins break before I take a 1-hour break for dinner!&lt;/p&gt;

&lt;p&gt;I try to schedule my meeting calls after dinner, so it’s relaxing work! Also, I try to spend some time learning things related to work this time. This helps me grow; suppose you are doing a react task, maybe you can look online at how people are doing the same thing and become more efficient in your work. Nobody will tell you to do this; only you can make your routine in a way so grow with the company too!&lt;/p&gt;

&lt;p&gt;Then I usually do another deep focus work session of 45mins with a 15mins break after it.&lt;/p&gt;

&lt;p&gt;I’m generally tired after all the focus sessions in the final hour of the work! So I do some different tasks like checking the Jira, updating tickets, writing new tickets sometimes. Improving our documentation or codebase sometimes, sometimes I just do pair programming with any developer to solve something quickly! We are a small team, so there are not many changes in the codebase every day, but I try to read all merge requests every day. Just look through it, so the codebase seems familiar to me if I work on the same part of it.&lt;/p&gt;

&lt;p&gt;This is what kind of my day looks like. Most of the time, it doesn’t go with the plan but try to stick to the first part of the day. I am doing three focus sessions to solve all my tickets on hand. I usually don’t touch my phone in the focus session, not opening any social media, not chatting! I don’t do that to focus entirely on the work. This way, I can do more in less time, which helps me relax later!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbkqydvr9g0xam0al03xe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbkqydvr9g0xam0al03xe.png" alt="Routine part 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the last part, I mention that your routine is entirely yours. How you become productive depends on you! It’s not a generic solution; find your own and make it better. I’ve put my whole routine in the blog. I hope this will help you to organize your day better!&lt;/p&gt;

&lt;p&gt;Feel free to message me anytime with any questions!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Logitech k380 Review: A multi-device Bluetooth Keyboard (Great choice for travel)</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Fri, 14 Jan 2022 15:53:15 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/logitech-k380-review-a-multi-device-bluetooth-keyboard-great-choice-for-travel-54mb</link>
      <guid>https://dev.to/nerdjfpb/logitech-k380-review-a-multi-device-bluetooth-keyboard-great-choice-for-travel-54mb</guid>
      <description>&lt;p&gt;A good keyboard can set your mood any day! I was looking for a new keyboard to carry here and there, and I found this beauty! This Logitech keyboard looks super cool when I first look at it. However, it was pretty expensive because I had never brought a keyboard for more than 10$ before. It cost me around 30$.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build
&lt;/h2&gt;

&lt;p&gt;I’ll suggest going through Logitech official website page for the details about it – &lt;a href="https://www.logitech.com/en-my/products/keyboards/k380-multi-device.920-009579.html"&gt;https://www.logitech.com/en-my/products/keyboards/k380-multi-device.920-009579.html&lt;/a&gt;&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CYru8Yuh7ob/embed/captioned"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Impact on my life
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Three device connectivity:&lt;/strong&gt; This is one of the main reasons I wanted to buy it. It’s super easy to connect with multiple devices at the same time. I can use it with my desktop; also with my laptop. Easy to switch. Take really low time to reconnect. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windows &amp;amp; Mac support:&lt;/strong&gt; Another fantastic feature of this keyboard. You can use just it with mac or windows, and it has specific keys for both! If you have a desktop &amp;amp; a MacBook, this can be an excellent choice!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compact size:&lt;/strong&gt; It’s a small, compact size keyboard. I like a big keyboard, but it’s fun to type and has enough space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy to travel with:&lt;/strong&gt; If you are traveling and thinking about getting a keyboard with you, this is one of the best. I’ve taken this one to multiple places, and the experience was great!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Buttons are comfortable:&lt;/strong&gt; It has round keys. If you are coming from square keys, it can be a slight issue at the start. But somehow, it’s super comfortable. My typing speed is impressive with it. I got around 90+ words per min with this one!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I’m missing in it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numberpad:&lt;/strong&gt; I’m more into big keyboards, so I miss the number pad here. But as a travel one, this is nothing serious!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Battery:&lt;/strong&gt; It uses an AAA battery, so I can’t see how much charge it has like other devices. This is sad because I don’t know when it will die. So I’ve to keep the battery on storage, but when I travel, maybe there can be some point I’ll not find the battery because I don’t carry the battery with me.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Getting a proper keyboard is needed. Otherwise, this can affect you in multiple ways. So spend a little bit of time choosing the proper one. Proper one can help you do different stuff efficiently, and if you want to try this model, go ahead and feel free to try it. It’s a fantastic keyboard for sure!&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CMcHe33JCJZ/embed/captioned"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;


</description>
      <category>productivity</category>
    </item>
    <item>
      <title>How to ask online as a beginner programmer?</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Fri, 07 Jan 2022 09:55:38 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-ask-online-as-a-beginner-programmer-49ab</link>
      <guid>https://dev.to/nerdjfpb/how-to-ask-online-as-a-beginner-programmer-49ab</guid>
      <description>&lt;p&gt;Learning something new is always harder, where to start! But most probably, if you are reading this, you’ve already started doing something extraordinary. Today, I will cover how to ask on the internet when you are just beginning as a programmer. Many newbies don’t know properly how to ask, and they get no reply from people. I help people using my Instagram, so I know how many weird things newbies usually ask. Still, it’s my personal opinion, so feel free to add more stuff down!&lt;/p&gt;

&lt;h2&gt;
  
  
  Googling
&lt;/h2&gt;

&lt;p&gt;Googling is a must-needed skill for a newbie. You don’t know how to search and get ideas most of the time. I am not a super expert in this field, but I can do enough. But let me tell you the secret. First, try to search for the problem you have. Most of the time, you’ll find nothing (because you are just putting the whole error message in google, which google doesn’t understand correctly). So try to break it down. Get some part of error the put the language name after it. This way, you’ll get somewhere, not keep checking. Before asking anyone, you should do this. Without googling and spending at least 10mins on google, never ask anyone anything. It doesn’t matter what it is; keep searching for 10mins, and please check the second page of google too!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1477632101335781378-164" src="https://platform.twitter.com/embed/Tweet.html?id=1477632101335781378"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1477632101335781378-164');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1477632101335781378&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  YouTube
&lt;/h2&gt;

&lt;p&gt;There are so many content creators nowadays, so if you search your issue on YouTube, there is a massive chance that you’ll find it. If you don’t understand English well, just search for it in your language. So many local people are making content nowadays. Nobody can’t teach you everything, so don’t just hook into one single person; use multiple creators to get ideas in your head. Watch numerous explanations on each topic. Suppose you do not understand recursion properly – search recursion in your language, then recursion if it’s a concept. Try to find an animation for it.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1478443504745410566-839" src="https://platform.twitter.com/embed/Tweet.html?id=1478443504745410566"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1478443504745410566-839');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1478443504745410566&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  Asking questions
&lt;/h2&gt;

&lt;p&gt;Finally, if you don’t find what you are looking for on google/youtube. Time to ask people, so where can we find people to ask? Tough one, right? The good thing is that there are so many helping people in the world that you’ll find help without making tough choices. For programming questions, you should go to StackOverflow (which doesn’t guarantee that people will answer) so go to some instant messaging apps like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;discord&lt;/li&gt;
&lt;li&gt;slack&lt;/li&gt;
&lt;li&gt;whatsApp&lt;/li&gt;
&lt;li&gt;telegram
You’ll find so many groups of programming and ask there! Okay, but general groups don’t give you a guarantee that you’ll find some solutions. So usually go to a specific group for asking a particular question. Suppose you are looking for a “react” answer. First, join a few react communities; how to find it? One of the quick ways is going to respond and check the community. You’ll mostly find something in there! Reactiflux is an excellent choice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2evs0ybjyigaqxeje1qe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2evs0ybjyigaqxeje1qe.png" alt="community for react"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Same thing you can do for vue and find some excellent links for vue! Most of the products nowadays have a community! If you find nothing, maybe check their repo in GitHub (which can help to ask something in there; or try to ask them on Twitter by tagging them in your post)&lt;/p&gt;

&lt;p&gt;So now the main question is how to ask? Normally if it’s a general question, you can find it on google, so you don’t have to go for someone to ask. So you have a specific case to ask, right? If it’s a code-related issue, you need to share your code with the particular question. How to do it?&lt;/p&gt;

&lt;p&gt;If it’s a small question, go to carbon and paste your code and share the screenshot. If it’s a more significant part of code, maybe this idea doesn’t work well, then make a public Github repo and share the repo (but it’ll be better if you can specifically tell people where to start looking). If possible, make a diagram to show how things are moving in your app. If it’s a CSS issue, then it’s tough for people to help with that without running, so maybe try to host it somewhere so that people can click and go to the link. With the link, anyone can inspect that help with CSS issues from their browser.&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CYRK_-gFdM-/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;


&lt;p&gt;Be smart with what you are asking; if you can’t ask correctly, people will ignore you because they don’t have time to work with your ugly screenshot! They have their own life! So be specific on the point with the helpful stuff; maybe you’ll solve your property before asking anyone in this process. When coding for a reasonable amount of time, we forget the logic we build, or sometimes we focus less on the whole picture! So once we try to explain it to someone else, our brain finds the solution in explaining time. It has happened to me many times; I’m not sure if the brain works in this way. Either way, it’s worth trying!&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CYWAah-FmoB/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  How to keep up to date with the tech industry?
&lt;/h2&gt;

&lt;p&gt;This is one of the great questions of any newbie. So try to follow people on Twitter. Instagram has many people who share programming content; you can follow there too! Facebook has some, but I use Instagram &amp;amp; Twitter for programming content. Reddit can be a good choice too!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1479072052166356993-888" src="https://platform.twitter.com/embed/Tweet.html?id=1479072052166356993"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1479072052166356993-888');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1479072052166356993&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;I hope this blog will help at least a little in your journey! Remember, it’s a marathon; you can’t win in one hour, one day, or one month. You need to keep learning and building skills!&lt;/p&gt;

&lt;p&gt;This post is originally published on &lt;a href="https://blog.nerdjfpb.com/how-to-ask-online-as-a-beginner-programmer/" rel="noopener noreferrer"&gt;NERDJFPB BLOG&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’ve community where we help each other to learn programming; if you are interest. Feel free to join – &lt;a href="https://discord.com/invite/CaUPRUnckR" rel="noopener noreferrer"&gt;https://discord.com/invite/CaUPRUnckR&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>One level deeper with web development in 2021 (Year review)</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Mon, 20 Dec 2021 13:45:24 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/one-level-deeper-with-web-development-in-2021-year-review-563p</link>
      <guid>https://dev.to/nerdjfpb/one-level-deeper-with-web-development-in-2021-year-review-563p</guid>
      <description>&lt;p&gt;2021 is a particular year for my career because I’m reaching a new height this year. I’m writing this review so anyone can understand how much a mid-level developer can do in a year! Let’s hop inside –&lt;/p&gt;

&lt;h3&gt;
  
  
  Things I learned
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Golang &amp;amp; Micro-Sevices &amp;amp; Google Cloud &amp;amp; Netsuite
&lt;/h2&gt;

&lt;p&gt;This year I’ll say I learned about golang for working in microservices for my current company. For my good work for the company, they switched me into the “golang” team, where I’ve helped automate some business stuff + handle NetSuite (which experience was terrible). Google cloud is something else that I learned this year! Working with micro-services, golang and for business actually gave me more wings this year to explore! &lt;/p&gt;

&lt;h2&gt;
  
  
  More Next JS
&lt;/h2&gt;

&lt;p&gt;We are using an old version of nextjs. We are not up to date because it’s hard to move from the old one. Lots of things broke; we don’t have time to upgrade because it was a busy year for us (just business is getting better after the corona). I pushed much nextjs code into production this year!&lt;/p&gt;

&lt;h2&gt;
  
  
  Typescript
&lt;/h2&gt;

&lt;p&gt;I got a chance to work part-time, where I started using typescript and loving it. It’s making my project super easy to work with, but honestly, I’m not great with typescript yet. I use type most of the place because I try to do functions more with nextjs, instead of using any class. I try to going with functional programming more!&lt;/p&gt;

&lt;h2&gt;
  
  
  Material UI ~ MUI 5
&lt;/h2&gt;

&lt;p&gt;We just got an update of MUI 5 a few months ago; loving the new look and sx props here for styling. The current module is best; I don’t even need to get some old-style type that saves much time!&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing content
&lt;/h2&gt;

&lt;p&gt;This year opened a few new doors for me. I got a chance to write for logRocket, Aviyel, which is pretty amazing right? I didn’t ask them to give me work, but they reached out to me from my blogs. So keep blogging! Success is just a few blogs away! I have been writing content for the last two years but didn’t get any offers before this year. So don’t think suddenly it came! &lt;/p&gt;

&lt;h2&gt;
  
  
  Working with multiple teams at a time
&lt;/h2&gt;

&lt;p&gt;I worked with so many people this year and learned much stuff. For communication, I mostly use slack &amp;amp; discord. This year’s notion helped me track down everything I’m doing with different teams &amp;amp; companies.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I stay productive
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Using a routine
&lt;/h2&gt;

&lt;p&gt;Using a routine is a must and must when trying to be productive. Usually, I start my working day two hours earlier than my full-time job, and this time I try to spend on part-time/learning. Also, I’ve two days off in a week. I use one day for my part-time content creation, and another day I take complete rest, and within a few weeks, I usually take two days off from my work. Taking breaks from regular life helps a lot to focus more!&lt;/p&gt;

&lt;h2&gt;
  
  
  Plan the week if possible
&lt;/h2&gt;

&lt;p&gt;Every Monday, I spend some time working on this week’s schedule. I try to schedule on my notion and follow that throughout the week. But honestly, it’s hard to maintain. Most of the time, things don’t work with a plan, but making a plan gives an idea of how the mess will be this week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using notion
&lt;/h2&gt;

&lt;p&gt;At first, when I saw people are using the notion, I was so irritated because I didn’t want to learn a new system to take notes. But after learning it a bit and finding out how powerful the notion is. Now I use it everyday; I even do my monthly budget here!&lt;/p&gt;

&lt;h3&gt;
  
  
  Things I’ve planned to do this year but failed
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Failed ~ Freelancing helping hand
&lt;/h2&gt;

&lt;p&gt;I was getting some freelance projects from different clients, and sadly I didn’t have enough time to work on this. So I asked my one friend to help with it. But sadly the things didn’t turn well. He was not replying to my messages well; he didn’t have enough sincerity to work. I had to do a lot of extra hours to fix his mess. Freelance projects are hard to maintain because they usually have a specific deadline and need to handle the client (feedback is the issue here). So this plan didn’t work!&lt;/p&gt;

&lt;h2&gt;
  
  
  Failed ~ Blog Idea
&lt;/h2&gt;

&lt;p&gt;After watching my personal blog growth, I felt like let’s try a tutorial blog with a few people, and I got some people to work with the same idea. But it looks like without getting paid; nobody is attentive to building something. So I had to ditch this idea after writing a few blogs with everyone! So this one failed too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things I’ve accomplished so far
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pushed microservices stuff into production&lt;/li&gt;
&lt;li&gt;Lots of reactjs stuff into prod (with bugs)&lt;/li&gt;
&lt;li&gt;Getting a fantastic part-time project (hourly basis)&lt;/li&gt;
&lt;li&gt;Writing paid contents&lt;/li&gt;
&lt;li&gt;Learned from my mistakes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Plans for the next year
&lt;/h2&gt;

&lt;p&gt;Dev advocate from a full stack developer (if you want to learn more about this, follow my journey anywhere – &lt;a href="https://www.instagram.com/nerd_jfpb/"&gt;Instagram&lt;/a&gt;, &lt;a href="https://twitter.com/nerdjfpb"&gt;Twitter&lt;/a&gt;, or &lt;a href="https://discord.com/invite/WBvHdMCYC7"&gt;discord server&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  How can anyone do the same as me? Advice for juniors!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Things take time so take it easy.&lt;/li&gt;
&lt;li&gt;Make a good routine to work with&lt;/li&gt;
&lt;li&gt;Share your ideas with the world.&lt;/li&gt;
&lt;li&gt;Create content and make it free so that people can find you&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope 2022 will be a fantastic year for all of you!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>programming</category>
      <category>yearinreview</category>
    </item>
    <item>
      <title>Building a simple alarm clock with Dasha, Express, Ejs and tailwind which force user to wake up</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Sun, 12 Dec 2021 19:55:40 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/building-a-simple-alarm-clock-with-dasha-express-ejs-and-tailwind-which-force-user-to-wake-up-5b7a</link>
      <guid>https://dev.to/nerdjfpb/building-a-simple-alarm-clock-with-dasha-express-ejs-and-tailwind-which-force-user-to-wake-up-5b7a</guid>
      <description>&lt;p&gt;Most probably, the title doesn't give a good idea about what we will build together today! We are trying to build an alarm clock that will call users and solve a riddle. It'd not cut the call unless they got it correct. But there is a chance of saying no if they don't want to wake up at that point. This blog will be vast if I complete the full features. So I'll try to make a minimal version where we'll use Dasha(&lt;a href="https://dasha.ai/"&gt;https://dasha.ai/&lt;/a&gt;) to make this. We are going to use &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Npm (for installing packages)&lt;/li&gt;
&lt;li&gt;Express js (For the API development) &lt;/li&gt;
&lt;li&gt;Ejs (templating language for HTML)&lt;/li&gt;
&lt;li&gt;TailwindCSS (for styling)&lt;/li&gt;
&lt;li&gt;Dasha (for making alarm clock interesting with the help of conversational AI)&lt;/li&gt;
&lt;li&gt;Vscode (code editor)&lt;/li&gt;
&lt;li&gt;Github (for getting dasha blank app)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start building, but before that, let's learn what it'll look like. Here is the final screenshot - &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bFgSgEkv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6su8s7rfocwjcyeuixfk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bFgSgEkv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6su8s7rfocwjcyeuixfk.png" alt="final screenshot" width="880" height="650"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By putting the phone number, we'll get a call to give the correct answer to end the call! We will build a short version of it because otherwise, the blog will be vast and hard to follow. &lt;/p&gt;

&lt;p&gt;Let's explore the Dasha first about learning how we can start. For using Dasha, you need to get an account there first. It's straightforward to register an account in Dasha; go to this URL (&lt;a href="https://auth.dasha.ai/account/register"&gt;https://auth.dasha.ai/account/register&lt;/a&gt;) and register your account for your key. It's still in beta mode, so that UI can change from time to time.&lt;/p&gt;

&lt;p&gt;Now, let's install the Dasha to log in and use its features. We are following this URL (&lt;a href="https://docs.dasha.ai/en-us/default"&gt;https://docs.dasha.ai/en-us/default&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g "@dasha.ai/cli@latest"
dasha account login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the login, it'll be better to install Dasha studio in our vscode &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VxF4DJ70--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibqvbpnjgcu9o3xeyqdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VxF4DJ70--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibqvbpnjgcu9o3xeyqdd.png" alt="dasha studio" width="880" height="753"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use a blank app from Dasha to build our part! Let clone it from Github.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/dasha-samples/blank-slate-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's install the packages to run it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we install, we've two paths to run this, either we can use chat or phone. I prefer the phone way so we'll run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start PHONE_NUMBER_HERE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this will get me a call on my phone to talk with the Dasha AI bot. But the most exciting part is that there is nothing much to talk about, as this is a small functionality. So let's look at what we've inside &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wfd089Nq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xom7w9t3ctqvgjctuwpd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wfd089Nq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xom7w9t3ctqvgjctuwpd.png" alt="folder structure" width="237" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The basic app comes with lots of stuff, but first, ignore the index.js file because that one is set up to run the Dasha part. So let's go to the app folder and look into the &lt;code&gt;main.dsl&lt;/code&gt; where things started!&lt;/p&gt;

&lt;p&gt;It quite looks like another programming, but there is some weird thing going on, right? Confusing right? It's a Dasha Scripting Language! So it's a little different from others. &lt;br&gt;
If we look into the first part&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "commonReactions/all.dsl";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's importing something, we can check the common reactions folder, and it'll give us some idea about what is happening here. We are loading some prewritten libraries here. So we can ignore this part for now, and let's go to the second part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context 
{
    input phone: string;
    input name: string = ""; 
    var1: string = "";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where we are getting the variables and doing stuff; we can create variables as we want from here and use them through this file. &lt;/p&gt;

&lt;p&gt;Below this, you'll find a function like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;external function function1(log: string): string;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also ignore this one because we're not going to use the complex stuff here. Let's check what is happening in the next part (root node)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root 
{
    do 
    {
        #connectSafe($phone); 
        #waitForSpeech(1000);
        #say("greeting", {name: $name} );
        wait *;
    }
    transitions 
    {
        yes: goto yes on #messageHasIntent("yes"); 
        no: goto no on #messageHasIntent("no"); 
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;start node root&lt;/code&gt; is the first part where the conversation will start. This node currently has two parts; this has a do &amp;amp; transition. In the &lt;code&gt;do&lt;/code&gt; part, it'll try to run it first; then, based on user talk, it'll go to function from transition. This basic app is a basic one, so it'll just ask if the user can hear the AI voice; if the user says something which has an intent of "yes" then it'll just go to "yes function"; otherwise, this will go in no intent route. &lt;/p&gt;

&lt;p&gt;Before exploring the next node, I'll start building our part because I think it's good enough to understand what's happening here. As we are going to develop the alarm clock, we can have the common reaction for our app, so in our main.dsl, we are going to import the common reaction first. We'll just keep the phone number input because we're going to connect users using the phone. so it'll look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "commonReactions/all.dsl";

context
{
    input phone: string;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it's time to write our main starting root. We are creating two-part of the start node root; the first part is done. Here we'll try to connect with the phone first; then, we'll try to delay a moment for a user to give a time, then AI will start talking. We'll use the #sayText function, where we'll write what AI will ask the user. Then we'll wait for the user to reply. Here the code -&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
    do
    {
        #connectSafe($phone);
        #waitForSpeech(1000);
        #sayText("Hello there! I am from Dasha AI and trying to call you as you requested! Are you interested to play a game?");
        wait *;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Based on the user response, we can't go anywhere right now, so we'll create transitions now. For this basic case, we'll either go with yes intention or no intention user.  The new code will look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
    do
    {
        #connectSafe($phone);
        #waitForSpeech(1000);
        #sayText("Hello there! I am from Dasha AI and trying to call you as you requested! Are you interested to play a game?");
        wait *;
    }
    transitions
    {
        yes: goto yes on #messageHasIntent("yes");
        no: goto no on #messageHasIntent("no");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you must be thinking about how it's getting the intent of a user? Is this prewritten? Yes! Because we've cloned the blank app repo, now it's time to explore the data.json file. &lt;code&gt;data.json&lt;/code&gt; file has all the intent listed for us. We are using yes &amp;amp; no intent for the first step, so we're not going to change anything right now and go back to our main.dsl file to write the transitions. So let's do the easy part first, suppose the user doesn't want to wake up and say something with no intent. What should we do? We need to on &lt;code&gt;no node&lt;/code&gt; to run the rest. Let's write a &lt;code&gt;no node&lt;/code&gt; for now -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node no
{
    do
    {
        #say("no");
        exit;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are not even writing a transition because we want to end the call when the user is not interested in waking up at this moment. But here, we didn't use any direct text like old-time; instead, we used #say("no"); which is going to data from &lt;code&gt;phrasemap.json&lt;/code&gt; file. Let's have a look in there and change the no text to new text so that it works well with our desired idea.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"no": 
      {
        "first": 
        [{ "text": "Understandable! Have a nice sleep!" }]
      },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This upper one will be our data in the &lt;code&gt;phrasemap.json&lt;/code&gt; file. If you create a custom phrasemap, don't forget to add that in &lt;code&gt;macros&lt;/code&gt; in the down part of &lt;code&gt;phrasemap.json&lt;/code&gt; file!&lt;/p&gt;

&lt;p&gt;Now time to build the yes part. So we're going to ask a riddle-type question here to help the user to wake up! Let's keep it simple and use #sayText to tell the text to the user and wait for his response, and based on his response, let's take a transition. The code will look like this -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node yes
{
    do
    {
        #sayText("I am tall when I am young, and I am short when I am old. What am I?");
        wait *;
    }

    transitions
    {
        correct: goto correct on #messageHasIntent("correctAnswer");
        no: goto no on #messageHasIntent("no");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are using two transitions; the first part is if they got the correct answer, then it'll go to a correct node. Otherwise, it'll repeat the question once (from the importing common reaction part). If the user doesn't guess correctly or try to say no, it'll end the call for now. This question is tricky, so for answering this question, the user needs to be wake &amp;amp; think, and this is the alarm part! Now let's build the final part of the puzzle, the correct answer node.&lt;/p&gt;

&lt;p&gt;The correct node will be really easy to work; we'll just say the answer is correct and end the call. Here is the simple node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node correct
{
    do
    {
        #sayText("This is a correct answer! Have a nice morning!");
        exit;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
'&lt;br&gt;
If it's hard to follow, you can check the whole code from the GitHub link -&amp;gt; (&lt;a href="https://github.com/nerdjfpb/Dasha-alarm-clock-example/blob/master/app/main.dsl"&gt;https://github.com/nerdjfpb/Dasha-alarm-clock-example/blob/master/app/main.dsl&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;We can test the app by running it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start PHONE_NUMBER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But we will improve the app and build a view for the app, so first, start with the API. First, we need to import the expressjs, ejs to start the UI part. &lt;br&gt;
For the express API endpoints, we are going to write (in index.js file, delete the dasha code for now)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// importing express js
const express = require('express')
const app = express()

// using for getting json input
app.use(express.json())

// setting the view engine js so that we can load the file from views/pages
app.set('view engine', 'ejs')

// for showing the ui 
app.get('/', (_req, res) =&amp;gt; {
  res.render('pages/index')
})

// post url to send the phone number and run the Dasha part
app.post('/', (req, res) =&amp;gt; {
  // Calling dasha will be happen here
  res.json({ success: true })
})

// port selection to run
const port = process.env.PORT || 3000
app.listen(port, () =&amp;gt; console.log(`listening on port ${port}`))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's write the view part; I'm using tailwindcss as CDN (which is a really bad idea, but I don't want to really install lots of stuff now and this one is mostly for demonstrating this tutorial). For the UI &lt;code&gt;index.ejs&lt;/code&gt; file will look like -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Alarm Clock By Dasha &amp;amp; Nodejs&amp;lt;/title&amp;gt;
  &amp;lt;script src="https://cdn.tailwindcss.com"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
  &amp;lt;main class="min-h-screen flex flex-col row-column items-center justify-center text-center"&amp;gt;
    &amp;lt;h1 class="text-4xl font-bold"&amp;gt;
      Alarm Clock With Dasha AI
    &amp;lt;/h1&amp;gt;
    &amp;lt;div class="text-gray-400 text-xs italic py-2"&amp;gt;please add the country code before your number&amp;lt;/div&amp;gt;

    &amp;lt;form class="min-w-[40%]" onsubmit="return handleOnSubmit(event)" method="get" action="#"&amp;gt;
      &amp;lt;input
        class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
        id="phone" type="text" placeholder="Enter your number..." /&amp;gt;

      &amp;lt;button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded my-2" type="submit"&amp;gt;
        Alarm Call
      &amp;lt;/button&amp;gt;

    &amp;lt;/form&amp;gt;
  &amp;lt;/main&amp;gt;

  &amp;lt;script&amp;gt;

    function handleOnSubmit(e) {
      e.preventDefault();

      const phone = document.getElementById('phone').value

      if (phone) {
        postData('/', { phone })
          .then(data =&amp;gt; {
            if (data.success) {
              alert('Alarm call is coming on your way! Please wait....')
            } else {
              alert('Something went wrong!')
            }
          });
      }

    }


    async function postData(url = '', data = {}) {
      const response = await fetch(url, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },

        body: JSON.stringify(data)
      });
      return response.json();
    }
  &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can get the file from here -&amp;gt; &lt;a href="https://github.com/nerdjfpb/Dasha-alarm-clock-example/blob/master/views/pages/index.ejs"&gt;https://github.com/nerdjfpb/Dasha-alarm-clock-example/blob/master/views/pages/index.ejs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are ready to finalize the last part for running the Dasha once the user clicks on the &lt;code&gt;Alarm Call&lt;/code&gt;. First, require the dasha&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const dasha = require('@dasha.ai/sdk')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we'll simply use the things from &lt;code&gt;blank-slate-app&lt;/code&gt; we are not going to use everything from there; we are just going to use it for a phone call, and here is the simple version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
async function dashaCall(phone) {
  const app = await dasha.deploy('./app')

  app.connectionProvider = async (conv) =&amp;gt;
    conv.input.phone === 'chat'
      ? dasha.chat.connect(await dasha.chat.createConsoleChat())
      : dasha.sip.connect(new dasha.sip.Endpoint('default'))

  app.ttsDispatcher = () =&amp;gt; 'dasha'

  app.setExternal('function1', (args) =&amp;gt; {
    console.log(args.log)
  })

  await app.start()

  const conv = app.createConversation({ phone: phone })

  if (conv.input.phone !== 'chat') conv.on('transcription', console.log)

  const result = await conv.execute()

  console.log(result.output)

  await app.stop()
  app.dispose()
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Call this function from the post part of &lt;code&gt;index.js&lt;/code&gt;, which will look like -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.post('/', (req, res) =&amp;gt; {
  dashaCall(req.body.phone)
  res.json({ success: true })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we are ready to run our app by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it will load, and you can put your number here to get a call from AI. &lt;/p&gt;

&lt;p&gt;This app simplifies the overall idea; we can improve a lot. Like&lt;br&gt;
Riddles can be randomize&lt;br&gt;
UI can be rich with a dashboard and alarm time (which I didn't make because this will be really hard to follow if I do that)&lt;br&gt;
Sometimes users can just ignore the call, so if users can't solve a riddle, we should call them again. This feature we can add. We could put a number in the database if they correctly answered. Based on that, we can call again!&lt;/p&gt;

&lt;p&gt;Overall there is a lot of scopes to improve. But this was a plan to demonstrate Dasha's conversational ai, which is fun to play with. I hope you enjoyed this tutorial. &lt;/p&gt;

&lt;p&gt;If you are looking for the whole code, here is the Github repo - &lt;a href="https://github.com/nerdjfpb/Dasha-alarm-clock-example"&gt;https://github.com/nerdjfpb/Dasha-alarm-clock-example&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to create a documentation site &amp; GitHub Page using Docz with NextJs and Typescript</title>
      <dc:creator>Muhammad Ali (Nerdjfpb)</dc:creator>
      <pubDate>Tue, 21 Sep 2021 13:12:26 +0000</pubDate>
      <link>https://dev.to/nerdjfpb/how-to-create-a-documentation-site-github-page-using-docz-with-nextjs-and-typescript-n37</link>
      <guid>https://dev.to/nerdjfpb/how-to-create-a-documentation-site-github-page-using-docz-with-nextjs-and-typescript-n37</guid>
      <description>&lt;h1&gt;
  
  
  Motivation
&lt;/h1&gt;

&lt;p&gt;Making good documentation can help understand a project better. It also saves much time! Creating good documentation and showcasing is a tedious task for big projects. In this blog, we will be going over how to maintain documentation for big projects. We chose Docz for the documentation. Read the rest of the blog to find out why!&lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisite
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;React JS basics&lt;/li&gt;
&lt;li&gt;Typescript basics&lt;/li&gt;
&lt;li&gt;Github basics&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Project Technical Needs
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Node JS - &lt;a href="https://nodejs.org/en/"&gt;https://nodejs.org/en/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Visual Studio Code - &lt;a href="https://code.visualstudio.com/"&gt;https://code.visualstudio.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Github account - &lt;a href="https://github.com/"&gt;https://github.com/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Why Chose Docz for All Your Software Documentation Needs
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;It’s powered by Gatsby, so easy to change themes, and we can give a great look to our documentation.&lt;/li&gt;
&lt;li&gt;There is no complex configuration in Docz, it is very straightforward.&lt;/li&gt;
&lt;li&gt;MDX is getting popular and widely used nowadays. In Docz, we have the power to write MDX.&lt;/li&gt;
&lt;li&gt;Finally, the typescript support is available in Docz. Typescript helps a project to maintain easily, and with Docz integration, it becomes super easy to make documentation. Try the blog for more information.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  How to start (initializing the nextjs with typescript)
&lt;/h1&gt;

&lt;p&gt;Initializing a project is super easy. Thanks to nextjs team for this. They already have a typescript boilerplate which will help us to start this quickly. Try&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app --ts nextdoczts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app --typescript nextdoczts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to find out the rest? Follow the link - &lt;a href="https://aviyel.com/post/824/how-to-create-a-documentation-site-github-page-using-docz-with-nextjs-and-typescript"&gt;https://aviyel.com/post/824/how-to-create-a-documentation-site-github-page-using-docz-with-nextjs-and-typescript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>github</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
