<?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: Tirth Patel</title>
    <description>The latest articles on DEV Community by Tirth Patel (@tirthpatel).</description>
    <link>https://dev.to/tirthpatel</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%2F608726%2Fc0853c52-556c-477a-97ba-6c18b227e245.jpeg</url>
      <title>DEV Community: Tirth Patel</title>
      <link>https://dev.to/tirthpatel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tirthpatel"/>
    <language>en</language>
    <item>
      <title>Python Portfolio - Dynamic Invitation Image Generator</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Sun, 19 Mar 2023 18:02:54 +0000</pubDate>
      <link>https://dev.to/tirthpatel/python-portfolio-dynamic-invitation-image-generator-1b2g</link>
      <guid>https://dev.to/tirthpatel/python-portfolio-dynamic-invitation-image-generator-1b2g</guid>
      <description>&lt;p&gt;Whenever you are host of any event, sending invitations to your near &amp;amp; dear ones is major task. And sometimes tedious also if your guest count is big. 😣&lt;/p&gt;

&lt;p&gt;Suppose, you plan to send a personalized invitation to each member that includes his/her name on it. This will need you a graphic designer who can sit all day long and can generate such personalized invitation posters with dynamic name on each. ⌨️ &lt;/p&gt;

&lt;p&gt;To solve your issue, I have made a tool in Python that leverages the power of OpenCV to implement image processing on a invitation poster. It can embed name (or any detail) on image and give you a separate poster for each invitee. 🕺&lt;/p&gt;



&lt;h2&gt;
  
  
  How to use the tool
&lt;/h2&gt;

&lt;p&gt;Here is a simple outline which you can follow:&lt;/p&gt;

&lt;p&gt;Let's take example of &lt;strong&gt;Birthday Invitation&lt;/strong&gt; to understand the execution of this tool.&lt;br&gt;
Source code : &lt;a href="https://github.com/tirth-2001/invitation-generator-python" rel="noopener noreferrer"&gt;Github Repo Link&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  1) Providing necessary details:
&lt;/h3&gt;

&lt;p&gt;You will have to give 2 details viz. &lt;em&gt;invitation poster image&lt;/em&gt; (jpg/png/jpeg) and &lt;em&gt;list of names&lt;/em&gt; (text file)&lt;/p&gt;

&lt;p&gt;Sample birthday invitation poster:&lt;br&gt;
(you need to put this image in code folder) &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%2Fbu01dtnmaffo32xygdzi.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%2Fbu01dtnmaffo32xygdzi.png" alt="Sample Poster"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;List of invitee names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mr. Tirth Patel
Ms. Sneha Shah
Mr. Bhavesh Jain
Mr. Rahul Singh
Mr. Rushi Patel
Mrs. Kavita Ahuja
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  2) Selecting location co-ordinates for where to put name.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You need select the location co-ordinates on the image at which you want to put the name of the invitee.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the code folder, please open &lt;code&gt;select_coordinate.py&lt;/code&gt; file and update the filename of invitation image which you are using.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you run it, double click on the image where you want to put the name. This can be trail &amp;amp; error excercise. Iterating this process 2-3 times will give you exact location you want.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  3) Hurrah! Lets generate personalized invitation for all
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Now we have image, names and co-ordinates where to put the name.&lt;/li&gt;
&lt;li&gt;Open &lt;code&gt;generate_invitation.py&lt;/code&gt; file and update the filename which you are going to use.&lt;/li&gt;
&lt;li&gt;Execute this python script in your IDE and you can see, personalized invitation is generated for all the invitees. (check the &lt;code&gt;outputs&lt;/code&gt; folder)&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%2Fu1isjo8fl82snsjwrtiw.jpg" 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%2Fu1isjo8fl82snsjwrtiw.jpg" alt="Invitation Collage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Scope of this tool 🚀
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;As of now, this tool only supports name on an Invitation poster. But the core concept is image processing. You can use it for multiple use cases. Like certificate generation, name tag generation, ID card generator and many more.&lt;/li&gt;
&lt;li&gt;Due to time constraints, I have limited the development scope to Python only. If you need some web app for this, please ping me in comment section.&lt;/li&gt;
&lt;li&gt;After Invitation generation, sending these personalized invitation is also a mammoth task. If you need to send them in Whatsapp, we can use Whatsapp API provided by Facebook to automate the generation and sending process. If your use case is to send on email, we can utilize Python or any such framework to send emails with the generated output.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Closing comments 🙋‍♂️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Thank you for reading along with me. If you find any queries on the topic mentioned above, please ping me in the comments. 💬&lt;/li&gt;
&lt;li&gt;Knowledge spreads by sharing. So please share this article with your concerned friends. 📱&lt;/li&gt;
&lt;li&gt;PS: Also, I humbly request you to write which topic you want in my next blog. I will include that in my target list. 🎯&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tirth Patel, signing off!🫡&lt;/p&gt;

</description>
      <category>python</category>
      <category>opencv</category>
      <category>imageprocessing</category>
      <category>portfolio</category>
    </item>
    <item>
      <title>5 ways to make React app super fast 🚀</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Sat, 11 Mar 2023 02:06:00 +0000</pubDate>
      <link>https://dev.to/tirthpatel/5-ways-to-make-react-app-super-fast-i0c</link>
      <guid>https://dev.to/tirthpatel/5-ways-to-make-react-app-super-fast-i0c</guid>
      <description>&lt;h3&gt;
  
  
  Are you struggling to make your gigantic react app more efficient in terms of &lt;strong&gt;Performance?&lt;/strong&gt; ⚡
&lt;/h3&gt;

&lt;p&gt;Don't worry! You've landed at the right location. These 5 methods will make your slow 🐢 React app into a fast app 🐇.&lt;/p&gt;

&lt;p&gt;For busy readers, here are the 5 methods in a nutshell.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;use callback&lt;/li&gt;
&lt;li&gt;useMemo&lt;/li&gt;
&lt;li&gt;memoized components&lt;/li&gt;
&lt;li&gt;Components Lazy import&lt;/li&gt;
&lt;li&gt;Image Lazy loading&lt;/li&gt;
&lt;/ol&gt;



&lt;h2&gt;
  
  
  1. useCallback
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When you declare a normal component, it runs each time when your component renders.&lt;/li&gt;
&lt;li&gt;Instead of declaring a normal function in the component, wrap it with useCallback.&lt;/li&gt;
&lt;li&gt;useCallback is a React hook that gives you a cached function. It is cached until any of its dependencies are changed.&lt;/li&gt;
&lt;li&gt;This way you get 2 benefits. 1) On change of any of its dependencies you get a fresh function respective to that value. 2) Unnecessary function calls are reduced which in turn increases the app's performance.&lt;/li&gt;
&lt;li&gt;Have a look at these basic conversions from normal functions to the useCallback function.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyProfile&lt;/span&gt;&lt;span class="p"&gt;:&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;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;birthYear&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;

  &lt;span class="c1"&gt;// normal function. this is called every time component renders&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;calculateAge&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;currentYear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getFullYear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;currentYear&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// efficient function. this will be called only when dependencies will be changed&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;efficientCalculateAge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&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;currentYear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getFullYear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;currentYear&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;birthYear&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;birthYear&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;Fragment&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;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Your Age : &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;efficientCalculateAge&lt;/span&gt;&lt;span class="p"&gt;()&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;p&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;Fragment&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;h2&gt;
  
  
  2. useMemo
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Typically in a React component, there are more variables than functions.&lt;/li&gt;
&lt;li&gt;Above we mentioned to cache functions. How if we can cache variables also? 🤔&lt;/li&gt;
&lt;li&gt;Here useMemo enters your game. Just do all the computation stuff and store the value wrapped with useMemo.&lt;/li&gt;
&lt;li&gt;Benefits of useMemo are the same as useCallback. Just the difference would be useMemo will return a variable while useCallback will return a function.&lt;/li&gt;
&lt;li&gt;Here is how you can simply implement useMemo in your project.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyCart&lt;/span&gt;&lt;span class="p"&gt;:&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;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;cartList&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;

  &lt;span class="c1"&gt;// this will be re-evaluated on every render&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;totalAmount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cartList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="c1"&gt;// this will be re-evaluated only when cartList changes&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;efficientTotalAmount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&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="nx"&gt;cartList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&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="nx"&gt;cartList&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;Fragment&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;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Total cart amount : &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;efficientTotalAmount&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;p&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;Fragment&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;h2&gt;
  
  
  3. memoized Components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Suppose you have Profile component. It includes 5 children components. So you might have noticed that even if the props of one child component have changed, all 5 will re-render. Have you thought WHY?&lt;/li&gt;
&lt;li&gt;It is because other children's components are not memoized.&lt;/li&gt;
&lt;li&gt;Technically we can understand a memo as It lets you skip re-rendering a component when its props are unchanged.&lt;/li&gt;
&lt;li&gt;It is also a kind of caching. Caching of components. Here when the parent component re-renders, it rerenders all of its children. React also does that. But if the component is memoized, React will return the unchanged cached copy of the component. This will eventually same computation time and in return, we'll get SPEED.⚡
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyProfile&lt;/span&gt;&lt;span class="p"&gt;:&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;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;userId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&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;cartList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCartList&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getCartListData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;number&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="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://jsonplaceholder.typicode.com/users/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;},[])&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&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="nf"&gt;getCartListData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;data&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="nf"&gt;setCartList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&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="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

  &lt;span class="c1"&gt;// MyCart component will be re-rendered only when cartList changes&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;Fragment&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;MyCart&lt;/span&gt; &lt;span class="na"&gt;cartList&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;cartList&lt;/span&gt;&lt;span class="si"&gt;}&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;Fragment&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;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyCart&lt;/span&gt;&lt;span class="p"&gt;:&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;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;props&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;cartList&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;

  &lt;span class="c1"&gt;// this will be re-evaluated on every render&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;totalAmount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cartList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="c1"&gt;// this will be re-evaluated only when cartList changes&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;efficientTotalAmount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&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="nx"&gt;cartList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&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="nx"&gt;cartList&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;Fragment&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;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Total cart amount : &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;efficientTotalAmount&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;p&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;Fragment&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;h2&gt;
  
  
  4. Lazy imports of components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Making a gigantic app includes hundreds of components. Some small, some big.&lt;/li&gt;
&lt;li&gt;To load all heavy (in terms of computation) components in one go will surely impact the app's startup time.&lt;/li&gt;
&lt;li&gt;Wise approach would be to dynamically import the components as and when required. We also call it Lazy Loading.&lt;/li&gt;
&lt;li&gt;Suppose there is a component called &lt;code&gt;&amp;lt;CropImage /&amp;gt;&lt;/code&gt;. It has some heavy libraries used in it. We can lazily load it when the user wants to open that.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;Fragment&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="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// importing CropImage as a lazy component&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CropImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./CropImage&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;MyProfile&lt;/span&gt;&lt;span class="p"&gt;:&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;FC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;// Using React.lazy and Suspense we can import the component only when it is needed&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CropImageComponent&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt; &lt;span class="na"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;=&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;Loading...&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="si"&gt;}&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;CropImage&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;Suspense&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;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;Fragment&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;CropImageComponent&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;Fragment&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;h2&gt;
  
  
  5. Lazy loading images
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Suppose any app requires 500 images in the entire project. If we load all 500 images at once, that will lead to heavy computation on the client side. (Internet required to load images etc)&lt;/li&gt;
&lt;li&gt;In this case, I would suggest lazily load images. Only when the user comes to the respective component where that image is required, the only image is loaded not at the start of the app.&lt;/li&gt;
&lt;li&gt;react-lazyload and react-image-lazy are some of the libraries which can make this happen.&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%2Fz4vv4gxjzkqcca8mzrqp.gif" 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%2Fz4vv4gxjzkqcca8mzrqp.gif" alt="Lazy load image"&gt;&lt;/a&gt;&lt;br&gt;
Source : &lt;a href="https://www.npmjs.com/package/react-lazy-load-image-component" rel="noopener noreferrer"&gt;react-lazy-load-image-component&lt;/a&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  Key takeaways 📝
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You shall use React hooks like &lt;code&gt;useCallback&lt;/code&gt; and &lt;code&gt;useMemo&lt;/code&gt; to take benefit of cached variables/functions. And get the latest update value whenever any of the dependencies are modified.&lt;/li&gt;
&lt;li&gt;Lazy loading gigantic and complex components is a wise choice, especially for a scalable app trying to improvise a performance.&lt;/li&gt;
&lt;li&gt;Assets such as images, videos, etc can also be used lazily as required.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Closing comments 🙋‍♂️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Thank you for reading along with me. If you find any queries on the topic mentioned above, please ping me in the comments. 💬&lt;/li&gt;
&lt;li&gt;Knowledge spreads by sharing. So please share this article with your concerned friends. 📱&lt;/li&gt;
&lt;li&gt;PS: Also, I humbly request you to write which topic you want in my next blog. I will include that in my target list. 🎯&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tirth Patel, signing off!🫡&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Run python in HTML : &lt;pyscript&gt;</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Wed, 18 Jan 2023 05:54:56 +0000</pubDate>
      <link>https://dev.to/tirthpatel/run-python-in-html--5fh4</link>
      <guid>https://dev.to/tirthpatel/run-python-in-html--5fh4</guid>
      <description>&lt;p&gt;Python was the foundation of my technical career. I gained my Python skills and worked on many AI/ML projects. But when I have to show the output, I cannot run the python file for each stakeholder. There were some limitations. It needs to be contained within a product, which can be portrayed on some kind of website or mobile app.&lt;/p&gt;

&lt;p&gt;Then, I had no idea how to build a bridge to connect these. Later, I learn about APIs (in Django/Flask) that can link my machine learning API with a web application so that users may use my API in a real sense.&lt;/p&gt;

&lt;p&gt;But that approach seems to be lengthy as well as costly (you need to host the Python API on a cloud server).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But thanks to PYSCRIPT... 🙌&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The pyscript team had brought a revolution in cross-platform connection technology.&lt;/p&gt;

&lt;p&gt;With the help of Pyscript, you can run Python in HTML. Just you need to import a JS script via CDN. And that's it. You are ready to rock.&lt;/p&gt;



&lt;h3&gt;
  
  
  Get Started
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The process to set up and run pyscript is very simple. Create an &lt;code&gt;index.html&lt;/code&gt; file and paste the below code.
&lt;/li&gt;
&lt;/ul&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;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"X-UA-Compatible"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"IE=edge"&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.0"&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;Python in HTML : Pyscript&lt;span class="nt"&gt;&amp;lt;/title&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;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://pyscript.net/latest/pyscript.css"&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;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Python in HTML : Pyscript&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;py-script&amp;gt;&lt;/span&gt;
            print("This hello world is written in Python and rendered in HTML using Python's print()")
        &lt;span class="nt"&gt;&amp;lt;/py-script&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;defer&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://pyscript.net/latest/pyscript.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&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;ul&gt;
&lt;li&gt;In the above code snippet you can see that, apart from the basic HTML boilerplate, we have added CSS and JS script of pyscript. And a special tag is provided by Pyscript. In which you can run Python commands. &lt;/li&gt;
&lt;li&gt;When you will open the &lt;code&gt;index.html&lt;/code&gt; file in the browser, you can see something similar to this:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fkr1tpaivsmanvhapdsfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fkr1tpaivsmanvhapdsfr.png" alt="Pyscript in HTML" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  Pre-cooked examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Pyscript has the ability to leverage HTML benefits along with the power of Python. So you can dig deep via &lt;a href="https://pyscript.net/examples/" rel="noopener noreferrer"&gt;Pyscript Example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Above website contains almost every segment of Pyscript from bottom to top. Starting from basic print functions to using Matplotlib and Numpy for Data Visualization.&lt;/li&gt;
&lt;li&gt;You check each example available on the above-mentioned link. (TIP: Run &lt;code&gt;Ctrl+U&lt;/code&gt; or &lt;code&gt;Right click -&amp;gt; View Page Source&lt;/code&gt; to check the HTML and pyscript code used in the respective example). Here are some snaps of a couple of demo examples.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fwksuzuigik9lb3dow3ve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fwksuzuigik9lb3dow3ve.png" alt="Data visualization" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxis66sshqjwtgv8jw4cd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxis66sshqjwtgv8jw4cd.png" alt="Pyscript Charts" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  How extensible is Pyscript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When Pyscript was launched, initially they have limited functionalities of Python integrated. Like REPL (Read, Eval, Print, Loop) and like that.&lt;/li&gt;
&lt;li&gt;But today, the horizon of Pyscript is way too big. You can use many Python libraries like Time, Numpy, Matplotlib, and many others.&lt;/li&gt;
&lt;li&gt;One of the most fascinating features which I like is the Import of external python files. It is just like importing a normal JS file in HTML and using the interwoven function of that.&lt;/li&gt;
&lt;li&gt;Similarly, you can also write complex python logic, ML APIs, and much more in a separate file. Import them in HTML, and leverage the benefit of Python via HTML.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  Closing comments 🙋‍♂️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Thank you for reading along with me. If you find any queries on the topic mentioned above, please ping me in the comments. 💬&lt;/li&gt;
&lt;li&gt;Knowledge spreads by sharing. So please share this article with your concerned friends. 📱&lt;/li&gt;
&lt;li&gt;PS: Also, I humbly request you to write which topic you want in my next blog. I will include that in my target list. 🎯&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tirth Patel, signing off! 🫡&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>MunchPay Node API - Apply semantic versioning</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Thu, 01 Dec 2022 18:29:53 +0000</pubDate>
      <link>https://dev.to/tirthpatel/munchpay-node-api-apply-semantic-versioning-5689</link>
      <guid>https://dev.to/tirthpatel/munchpay-node-api-apply-semantic-versioning-5689</guid>
      <description>&lt;h2&gt;
  
  
  Recalling SemVer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A quick revision of the Semantic Version. It consists of 3 sections.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAJOR.MINOR.PATCH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MAJOR:&lt;/strong&gt; It represents the major version of the app. Any incompatible change, API modification, or such changes are handled under this number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MINOR:&lt;/strong&gt; When you add new functionality in a backward compatible manner is introduced in the product. Any improvement (like performance, optimization, etc) can be covered under this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PATCH:&lt;/strong&gt; As the name suggests it is reserved for bug fixes internal to the system/product. Note that these bug fixes should be backward compatible.&lt;/p&gt;



&lt;h2&gt;
  
  
  Let's make MunchPay API 💰
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Let's make a basic payment API called as MunchPay. This API will have just 2 routes: 1) Get payment methods 2) Make payment&lt;/li&gt;
&lt;li&gt;To get started we need to have a Node App which can serve as an API server. For sake of this blog, I've used Express JS. These are the checkpoints that should be ready to move ahead.

&lt;ul&gt;
&lt;li&gt;Create a Node project&lt;/li&gt;
&lt;li&gt;Install the following npm packages: &lt;code&gt;express, nodemon&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Write boilerplate for express server&lt;/li&gt;
&lt;li&gt;Create 1 GET route: &lt;code&gt;getPaymentMethods&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create 1 POST route: &lt;code&gt;makePayment&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Update the scripts in package.json to spin up the server&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You can clone this repo &lt;a href="https://github.com/tirth-2001/munchpay-api" rel="noopener noreferrer"&gt;MunchPay API Get Started&lt;/a&gt; to align until this step.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Deploying dev version on public 🌐
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To deploy MunchPay API, we'll use Vercel. I have mentioned a detailed guide on how to deploy the Express JS app on Vercel in this &lt;a href="https://dev.to/tirthpatel/node-js-express-app-on-vercel-develop-run-deploy-524a"&gt;Deploy Node JS on Vercel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;To shorten the length of this article we're not covering each step here.&lt;/li&gt;
&lt;li&gt;Once API will be deployed you can see something like this. (If you don't want to deploy, running it on local server will also work)&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%2Fhqjtp0bolpqtxzzhlx69.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%2Fhqjtp0bolpqtxzzhlx69.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  Release the first version 1️⃣
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Let's make this API public and release the first stable version.&lt;/li&gt;
&lt;li&gt;NOTE: To declare a public API we need to maintain proper documentation of what is changed in each release.&lt;/li&gt;
&lt;li&gt;Create a README.md file at the root of the project. This will serve as documentation of our MunchPay API. (Actual APIs use other tools like Swagger/OpenAPI etc for maintaining documentation)&lt;/li&gt;
&lt;li&gt;Node projects give us a nice option to manage versions of our project.&lt;/li&gt;
&lt;li&gt;Go to the root of the project in a terminal. And execute this command :
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;ul&gt;
&lt;li&gt;This will show you the current version and prompt for a new version. Enter the new version as &lt;code&gt;1.0.0&lt;/code&gt;. As we're releasing for the first time, this will be the base version for our Public API.&lt;/li&gt;
&lt;li&gt;You will notice that the &lt;code&gt;yarn version&lt;/code&gt; command will also commit the version changes.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Planning new patch release 🏷️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Patch means any internal bug fixes with backward compatibility. This means this change should not break the end users' app.&lt;/li&gt;
&lt;li&gt;You can see &lt;code&gt;src/controllers/payment.js&lt;/code&gt; file. In this initially, we've artificially set up a bug. We're using amount value from request body for currency conversion. But validation is not done if amount is not passed in body. This is a potential bug.&lt;/li&gt;
&lt;li&gt;Let's rectify this. Replace the function with the following function. [&lt;code&gt;controllers/payment.js&lt;/code&gt;]
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// POST /makePayment&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/make-payment&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&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;amount&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&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="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Amount is required&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;convertedAmount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;convertINRToUSD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Payment Successfull ✅&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;convertedAmount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;mode&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;ul&gt;
&lt;li&gt;For PATCH the process can be something similar to this. Fix Bug →   Increment patch version → Update documentation (README in our case) → Deploy the changes&lt;/li&gt;
&lt;li&gt;Run
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Type version as: &lt;code&gt;1.0.1&lt;/code&gt;. Press enter to update the version.
&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%2Fheb9f7vxjnc01bxo6ktv.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt;Modify &lt;code&gt;README.md&lt;/code&gt; accordingly.&lt;/li&gt;
&lt;li&gt;Once version is updated you can ping base API to check latest API version. &lt;code&gt;localhost:8080&lt;/code&gt;
&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%2Fpy8q93hdqinvaz5jz8zc.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%2Fpy8q93hdqinvaz5jz8zc.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  Deploying new minor release 🔖
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MINOR means any internal improvement with backward compatibility. So this change should not break the user's app.&lt;/li&gt;
&lt;li&gt;You can perform any such change in our API. Currently, all available payment methods are static. You can call another API to fetch payment methods according to the user's region.&lt;/li&gt;
&lt;li&gt;Once those changes are done, further process is the same as we did in deploying the PATCH version.&lt;/li&gt;
&lt;li&gt; Modify code →  Increment minor version → Update documentation (README in our case) → Deploy the changes&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Publishing a major release ⭐
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MAJOR means a groundbreaking change that will affect end users.&lt;/li&gt;
&lt;li&gt;You can plan any such incompatible update in our API. Suppose you change the route name of &lt;code&gt;makePayment&lt;/code&gt; API or you change the method of &lt;code&gt;getPaymentMethods&lt;/code&gt; from GET to POST. (or any such change)&lt;/li&gt;
&lt;li&gt;Once those changes are done, further process is the same as we did in deploying the PATCH version.&lt;/li&gt;
&lt;li&gt; Modify code →  Increment major version → Update documentation (README in our case) → Deploy the changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NOTE:&lt;/strong&gt; When we increment a major version, minor and patch values must be pointed to 0. So now your API's version will be &lt;code&gt;2.0.0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Key takeaways 📝
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We saw how to plan patch, minor and major releases based on MunchPay payment API.&lt;/li&gt;
&lt;li&gt;Incrementing version and reflecting changes in the documentation must be done without fail for any new release (patch, minor or major)&lt;/li&gt;
&lt;li&gt;Deploying our Node API and releasing it for public use.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Closing Comments 🙋‍♂️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Thank you for following along with me. If you find any queries on the above-mentioned topic, please ping me in the comments.&lt;/li&gt;
&lt;li&gt;Knowledge spreads by sharing. So please share this article with your concerned friends.&lt;/li&gt;
&lt;li&gt;PS: Also, I humbly request you to write which topic you want in my next blog. I will include that in my target list. 🎯&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Tirth Patel, signing off! 🫡&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>4 Important Rules of Semantic Versioning</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Fri, 25 Nov 2022 11:52:35 +0000</pubDate>
      <link>https://dev.to/tirthpatel/wise-developers-choice-44mf</link>
      <guid>https://dev.to/tirthpatel/wise-developers-choice-44mf</guid>
      <description>&lt;p&gt;There are many things which a wise developer takes cares of. One of them is &lt;strong&gt;Semantic Versioning.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before jumping onto Semantic versioning, let's consider one example: &lt;/p&gt;

&lt;p&gt;Suppose you are developing an app named &lt;strong&gt;Building&lt;/strong&gt; 🏢. While building this app, you need to integrate a third-party package called &lt;strong&gt;Crane&lt;/strong&gt; 🏗️. When you installed Crane in your Building app, its version was 2.1.0. After some time you need one more package named &lt;strong&gt;Truck&lt;/strong&gt; 🚚, which was having 1.1.4 version. Among these 2 packages; Crane was not following the standards of Semantic Versioning. And package Truck was appropriately following the rules of semantic versioning.&lt;/p&gt;

&lt;p&gt;Let's pause this example here for a while and understand what is semantic versioning. At the end of article, we'll continue this example and see how Crane and Truck's releases will affect your Building app.&lt;/p&gt;



&lt;h3&gt;
  
  
  WHAT? ⚙️
&lt;/h3&gt;

&lt;p&gt;Semantic Versioning is also called as &lt;code&gt;SemVer&lt;/code&gt; for short notation. It is a standardized pattern to mark versions of any app, package, library, API, or any other product wherever it is applicable. (In the further article SemVer stands for Semantic Versioning)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAJOR.MINOR.PATCH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample SemVer(s)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- 2.4.0 (Major: 2, Minor: 4, Patch: 0)
- 4.6.2 (Major: 4, Minor: 6, Patch: 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Semantic Version consists of mainly 3 parts (it may be more depending on how many levels deep you want to take it)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MAJOR:&lt;/strong&gt; It represents the major version of the app. Any incompatible change, API modification, or such changes are handled under this number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MINOR:&lt;/strong&gt; When you add new functionality in a backward compatible manner is introduced in the product. Any improvement (like performance, optimization, etc) can be covered under this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PATCH:&lt;/strong&gt; As the name suggests it is reserved for bug fixes internal to the system/product. Note that these bug fixes should be backward compatible.&lt;/p&gt;



&lt;h3&gt;
  
  
  WHY? 📢
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Reduce dependency hell: Suppose in an app, you have 15 dependencies of third-party packages. If those 15 packages don't follow the proper practices of SemVer then you will not know which package to update and what impact it will make on the app.  At a point, you will end up in dependency hell where you will have to wait for third-party packages to update their versions in order to release your app. Practices rules of SemVer we can easily and efficiently do dependency management.&lt;/li&gt;
&lt;li&gt;Following standards for release planning and deployments: Any release's stability and lifespan can be judged by its SemVer. For CI/CD pipelines also appropriate versioning plays a vital role.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  RULES 📝
&lt;/h3&gt;

&lt;p&gt;There are some standard practices that should be followed while using Semantic Versioning. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;MAJOR, MINOR, PATCH must be whole numbers (0,1,2...). These should not include negative integers or decimal points.&lt;/li&gt;
&lt;li&gt;Once version details are published for any app, they should not be altered. Version values can only be changed as a new release.&lt;/li&gt;
&lt;li&gt;Comparing 2 SemVer must be from left to right based on the increasing value of the number. Ex : 1.0.0 &amp;lt; 1.1.0 &amp;lt; 2.0.0 &amp;lt; 2.0.1&lt;/li&gt;
&lt;li&gt;Major version 0 (0.x.y) is for the development phase. During this, the app must not be considered stable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(For more details visit &lt;a href="https://semver.org/"&gt;semver.org&lt;/a&gt;)&lt;/p&gt;



&lt;h3&gt;
  
  
  Completing our Building App 🏢
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Let's wind up our article by completing the example. We're building an app named Building. And among that; Crane was not following SemVer. The truck was following. &lt;/li&gt;
&lt;li&gt;When you plan the release of the Building app at that time 
🏗️ Crane's version -&amp;gt; 2.1.3 &amp;amp; 🚚 Truck's version -&amp;gt; 1.2.2. By this, we can predict that for Crane -&amp;gt; till version 2.x.y &amp;amp; Truck -&amp;gt; till version -&amp;gt; 1.p.q we can publish our app and there will be no breaking changes. &lt;/li&gt;
&lt;li&gt;But this surety can only be assured by a package Truck and not from Crane. The reason is Crane is not following SemVer standards. So in the next release Crane -&amp;gt; version 2.1.5 they might introduce some breaking changes of which we're unaware. &lt;/li&gt;
&lt;li&gt;If we're using more ill-planned packages like Crane, this can lead to dependency hell and end up in an issue for App. So be cautious to choose packages...&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  What about Practical ❓🤔
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Too much technical jargons so far... 😅. Only theory can't be sufficient. We'll look into the practical application of SemVer by developing a Node-based &lt;strong&gt;MunchPay API.&lt;/strong&gt; Where we'll check each aspect of versioning and deploying.&lt;/li&gt;
&lt;li&gt;Stay tuned for the continued series article: &lt;code&gt;Semantic Versioning in MunchPay Node API&lt;/code&gt; for practical exposure.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Closing comments 🙋‍♂️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Thank you for reading along with me. If you find any queries on the above-mentioned topic, please ping in the comments.&lt;/li&gt;
&lt;li&gt;Knowledge spreads by sharing. So please share this article with concerned friends.&lt;/li&gt;
&lt;li&gt;PS : Also, I humbly request you to write which topic you want in my next blog. I will include that in my target list. 🎯&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Tirth Patel, signing off! 🫡&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Deploy Node API (Express Typescript) on Vercel</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Wed, 16 Nov 2022 14:12:21 +0000</pubDate>
      <link>https://dev.to/tirthpatel/deploy-node-ts-express-typescript-on-vercel-284h</link>
      <guid>https://dev.to/tirthpatel/deploy-node-ts-express-typescript-on-vercel-284h</guid>
      <description>&lt;p&gt;A couple of weeks back, I developed an API in Node based on Typescript. I tried to deploy it on Heroku.&lt;/p&gt;

&lt;p&gt;But the process was long and time-consuming. Also, I noticed that Heroku is terminating free accounts from 28 Nov'22. ☹️&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%2F655kqvp273f7483woars.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%2F655kqvp273f7483woars.png" alt="Heroku" width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I tried to experiment with various other platforms to deploy my Typescript-based Node API. Amon them free, robust, and versatile platform I found is VERCEL. Based on my experience, here are a few simple steps which you can follow and easily deploy Typescript-based Node API on Vercel. 🚀&lt;/p&gt;



&lt;h3&gt;
  
  
  1) Express + Typescript Boilerplate App ✏️
&lt;/h3&gt;

&lt;p&gt;Create express project with typescript. You can follow the below-mentioned steps to make a boilerplate for the project. (Github repo link is provided at end of article)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Initialize node project&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Install packages (you can use npm/yarn/pnpm)&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add express
yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; typescript
yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; @types/node
yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; @types/express
yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; nodemon
yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; ts-node
&lt;/code&gt;&lt;/pre&gt;

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



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create &lt;code&gt;tsconfig.json&lt;/code&gt;&lt;br&gt;
To work with typescript we need to make tsconfig.json file which will help to compile and build Typescript files in plain JS. Execute below command&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tsc &lt;span class="nt"&gt;--init&lt;/span&gt; &lt;span class="nt"&gt;--rootDir&lt;/span&gt; src &lt;span class="nt"&gt;--outDir&lt;/span&gt; build &lt;span class="nt"&gt;--esModuleInterop&lt;/span&gt; &lt;span class="nt"&gt;--resolveJsonModule&lt;/span&gt; &lt;span class="nt"&gt;--lib&lt;/span&gt; es6 &lt;span class="nt"&gt;--module&lt;/span&gt; commonjs &lt;span class="nt"&gt;--allowJs&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="nt"&gt;--noImplicitAny&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;br&gt;&lt;br&gt;
    Once the file is created you can keep it as is, or cleanup non necessary stuff. Replace content of &lt;code&gt;tsconfig.json&lt;/code&gt; with following :&lt;br&gt;
&lt;br&gt;&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="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;"compilerOptions"&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="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"commonjs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"esModuleInterop"&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;"allowSyntheticDefaultImports"&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;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitAny"&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;"moduleResolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"sourceMap"&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;"outDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"baseUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&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;"paths"&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="nl"&gt;"*"&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="s2"&gt;"node_modules/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/types/*"&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="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"include"&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="s2"&gt;"./src/**/*"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Update &lt;code&gt;scripts&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nodemon src/index.ts"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

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



&lt;ul&gt;
&lt;li&gt;Write express server code : Create file : &lt;code&gt;src/index.ts&lt;/code&gt; and paste following code in it

&lt;/li&gt;
&lt;/ul&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="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Response&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="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;express&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;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;

  &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Express Typescript on Vercel&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/ping&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="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pong 🏓&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&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;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server is listening on &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;ul&gt;
&lt;li&gt;Spin up server : Run &lt;code&gt;yarn start&lt;/code&gt; or &lt;code&gt;npm run start&lt;/code&gt; command in terminal to start express serve. You can open browser and go to &lt;code&gt;localhost:8080&lt;/code&gt;. API will return response of &lt;code&gt;Express Typescript on Vercel&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  2) Initialize git in our project. 📥
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make a &lt;code&gt;.gitignore&lt;/code&gt; file in the root of the folder. And add &lt;code&gt;node_modules&lt;/code&gt; to it. If .gitignore file exists check that &lt;code&gt;node_modules&lt;/code&gt; is added into it.&lt;/li&gt;
&lt;li&gt;Execute &lt;code&gt;git init&lt;/code&gt; in the terminal (from root of project) or you can use VS Code's source control tab to initialize git repository.&lt;/li&gt;
&lt;li&gt;Connect local repo to remote (github/bitbucket). You can use any of the version control system to publish your repository.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  3) Create Vercel project 🗃️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to vercel.com -&amp;gt; Login&lt;/li&gt;
&lt;li&gt;Login using the Version control platform you have kept your repository.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the dashboard -&amp;gt; Add new project -&amp;gt; Select your repository -&amp;gt; Deploy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Afer deployment you will see something similar to this! 😟 &lt;/p&gt;&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%2F73euzi3stnat1mhc1wp3.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%2F73euzi3stnat1mhc1wp3.png" alt="Vercel Error" width="800" height="532"&gt;&lt;/a&gt;&lt;br&gt;
(ERROR 🚨)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't worry... Just follow on steps to fix it. 👍&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  4) Add Vercel config in app ⚙️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the above step, after your fist deploy is completed, you can see that we're not getting &lt;code&gt;Express Typescript on Vercel&lt;/code&gt; response from API.&lt;/li&gt;
&lt;li&gt;To work this as expected, we need to tell Vercel that is a API and you need to serve this as a serverless function.&lt;/li&gt;
&lt;li&gt;For this, simply we need to add &lt;code&gt;vercel.json&lt;/code&gt; file in root of our project. Paste below code in file.

&lt;/li&gt;
&lt;/ul&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;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"builds"&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"use"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@vercel/node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"config"&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="nl"&gt;"includeFiles"&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="s2"&gt;"dist/**"&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="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="nl"&gt;"routes"&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&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;"dest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.js"&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="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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;NOTE:&lt;/strong&gt; Check your tsconfig.json file. The value against &lt;code&gt;outDir&lt;/code&gt; must be kept instead of &lt;code&gt;dist&lt;/code&gt;. If your config file has any other value than &lt;code&gt;dist&lt;/code&gt;, replace it at either of both places.&lt;/p&gt;



&lt;h3&gt;
  
  
  5) Add a &lt;code&gt;pre-commit&lt;/code&gt; hook 🏷️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Vercel requires plain JS source files instead of Typescript. In order to do this, we need to build the project before committing and send compiled JS files so that Vercel can parse those files and serve the API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;code&gt;pre-commit&lt;/code&gt; and &lt;code&gt;rimraf&lt;/code&gt; package :&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; pre-commit
  yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; rimraf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;ul&gt;
&lt;li&gt;Modify &lt;code&gt;scripts&lt;/code&gt; field in &lt;code&gt;package.json&lt;/code&gt; file as follows:

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&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="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nodemon src/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rimraf dist &amp;amp;&amp;amp; tsc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"ts.check"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc --project tsconfig.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"add-build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"git add dist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"echo &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Error: no test specified&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &amp;amp;&amp;amp; exit 1"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;ul&gt;
&lt;li&gt;Add new field &lt;code&gt;pre-commit&lt;/code&gt; field in &lt;code&gt;package.json&lt;/code&gt; :

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"pre-commit"&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;"ts.check"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"add-build"&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;ul&gt;
&lt;li&gt;What this will do? → Whenever you will commit, the commands written in pre-commit will be executed. It will check Typescript errors, build the project and add build folder to the staged changes. (If you opt for manual build, don't forget to run build command to start build.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5) Re-Deploy and Re-Check API 🔁
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Commit the changes you have made and push the commit to GitHub. Check on vercel for the new deployment. Vercel will automatically trigger a new deployment on every push. Incase it is not started, you can manually start a deployment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once new deployment is live, you can copy the deploy URL and run in browser. You will see &lt;code&gt;Express Typescript on Vercel&lt;/code&gt; as a API response. Hurrah 😃&lt;/p&gt;&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%2Fc4q74fyx0yt39jo16igh.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%2Fc4q74fyx0yt39jo16igh.png" alt="API working" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To assure that API is working perfectly, you can also hit &lt;code&gt;/ping&lt;/code&gt; route which will return &lt;code&gt;pong 🏓&lt;/code&gt; as the response.&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%2Fodazv7ld1icmq3gj793u.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%2Fodazv7ld1icmq3gj793u.png" alt="Ping Pong response" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing comments 🙋‍♂️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Thank you for following steps with me. Incase you find any issue in above mentioned steps, please ping in comment.&lt;/li&gt;
&lt;li&gt;Also a humble request you to write which topic you want in my next blog. I will include that in my target list. 🎯&lt;/li&gt;
&lt;li&gt;Github repo link for this project : &lt;a href="https://github.com/tirth-2001/express-typescript-vercel-part2" rel="noopener noreferrer"&gt;Express Typescript Code&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Tirth Patel, signing off! 🫡&lt;/p&gt;

</description>
      <category>express</category>
      <category>typescript</category>
      <category>vercel</category>
      <category>node</category>
    </item>
    <item>
      <title>Deploy Express JS (Node App) on Vercel</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Wed, 09 Nov 2022 17:58:14 +0000</pubDate>
      <link>https://dev.to/tirthpatel/node-js-express-app-on-vercel-develop-run-deploy-524a</link>
      <guid>https://dev.to/tirthpatel/node-js-express-app-on-vercel-develop-run-deploy-524a</guid>
      <description>&lt;p&gt;After Heroku announced the termination of free plans 😏, it has become need for developers to find free alternatives to Heroku for deploying apps.&lt;/p&gt;

&lt;p&gt;While researching this, I found many options that can cater to our needs, viz. Digital Ocean, AWS, GCP, and many others. But these cloud providers need a dense setup, and the pricing is way too high.&lt;/p&gt;

&lt;p&gt;But I have 🎁 for you… &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can deploy your Express app on Vercel for FREE.&lt;/strong&gt; 🎉&lt;/p&gt;

&lt;p&gt;I’ll let you know steps by which you can easily deploy Express app on Vercel. (You can start from step 2/3 if you have existing Express JS App)&lt;/p&gt;

&lt;p&gt;PS: In this blog, especially I’m focusing on &lt;strong&gt;Node (Express) app&lt;/strong&gt;. For python or other tech stacks, we can discuss it in another blog. ⌚&lt;/p&gt;



&lt;h3&gt;
  
  
  1) Basic Express App 📝
&lt;/h3&gt;

&lt;p&gt;(if you already have one, you can skip this step. Github repo link at bottom of article)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Init Node JS app : Go to folder in which you want to create app and run following command&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Install packages : After app is initiated, install &lt;code&gt;express&lt;/code&gt; package using yarn/npm&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn add express / npm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

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



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Boilerplate for Express : Create &lt;code&gt;index.js&lt;/code&gt; file in root of the folder. And copy the below code snippet&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&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="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Express JS on Vercel&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/ping&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pong 🏓&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;

    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&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="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[INFO] Server Running on port:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;port&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;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Update NPM scripts : Add &lt;code&gt;start&lt;/code&gt; script in &lt;code&gt;scripts&lt;/code&gt; object&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&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="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node index.js"&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;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Spin up app : Start your app by running &lt;code&gt;yarn start&lt;/code&gt; or &lt;code&gt;npm run start&lt;/code&gt;. Upon starting server, open browser and navigate to &lt;code&gt;localhost:8080&lt;/code&gt;. You will get &lt;code&gt;Express JS on Vercel&lt;/code&gt; as a response from our Express app.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  2) Initialize git in our project. 💻
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make a

&lt;code&gt;.gitignore&lt;/code&gt;

file in the root of the folder. And add

&lt;code&gt;node_modules&lt;/code&gt;

to it. If .gitignore file exists check that

&lt;code&gt;node_modules&lt;/code&gt;

is added into it.&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Execute &lt;code&gt;git init&lt;/code&gt; in the terminal (from root of project) or you can use VS Code's source control tab to initialize git repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect local repo to remote (github/bitbucket). You can use any of the version control system to publish your repository.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  3) Create Vercel project 💾
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to vercel.com -&amp;gt; Login&lt;/li&gt;
&lt;li&gt;Login using the Version control platform you have kept your repository.&lt;/li&gt;
&lt;li&gt;From the dashboard -&amp;gt; Add new project -&amp;gt; Select your repository -&amp;gt; Deploy&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  4) Add Vercel config in app ⚙️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the above step, after your fist deploy is completed, you can see that we're not getting &lt;code&gt;Express JS on Vercel&lt;/code&gt; response from API.&lt;/li&gt;
&lt;li&gt;To work this as expected, we need to tell Vercel that this is an API and you need to serve this as a serverless function.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For this, simply we need to add &lt;code&gt;vercel.json&lt;/code&gt; file in root of our project. Paste below code in file&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;/p&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;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"builds"&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"use"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@now/node"&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="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"routes"&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&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;"dest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index.js"&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="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;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;NOTE: In the &lt;code&gt;dest&lt;/code&gt; field, please put the filename which is the base entry file of your project. Suppose you have &lt;code&gt;app.js&lt;/code&gt; as your base file you need to modify this config accordingly. Then only Vercel will know which file to serve as a base file for API execution.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  5) Re-Deploy and Re-Check API 🔁
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;After

&lt;code&gt;vercel.json&lt;/code&gt;

file is added, push these changes to git repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Vercel will automatically trigger a deployment when you push in your branch. If it doesn't trigger automatic deployment, you can start a manual deployment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the new deployment is live, you can now see by refreshing the VERCEL deploy URL and check that now we're getting&lt;br&gt;
&lt;br&gt;
&lt;code&gt;Express JS on Vercel&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
as a API response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To assure that API is working perfectly, you can also hit &lt;code&gt;/ping&lt;/code&gt; route which will return &lt;code&gt;pong 🏓&lt;/code&gt; as the response.&lt;/p&gt;&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%2Fxob61zov2atumwbfwum7.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%2Fxob61zov2atumwbfwum7.png" alt="Express JS App deployed on Vercel"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Github Repo Link : &lt;a href="https://github.com/tirth-2001/express-js-vercel-part1" rel="noopener noreferrer"&gt;Express JS on Vercel&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How can we forget Typescript❓🤔
&lt;/h2&gt;

&lt;p&gt;Stay tuned for a fresh new article on &lt;strong&gt;&lt;code&gt;Deploying Typescript based Express App on Vercel&lt;/code&gt;&lt;/strong&gt;. Coming soon...&lt;/p&gt;

&lt;p&gt;Tirth Patel, signing off! 🫡&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>express</category>
      <category>vercel</category>
      <category>node</category>
    </item>
    <item>
      <title>Create new branch from commit ID</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Thu, 27 Oct 2022 06:42:52 +0000</pubDate>
      <link>https://dev.to/tirthpatel/create-new-branch-from-commit-id-369p</link>
      <guid>https://dev.to/tirthpatel/create-new-branch-from-commit-id-369p</guid>
      <description>&lt;p&gt;Many times due to unwanted push/pull/merge your branch mess up with unwanted code. Some unncessary and buggy commits line up in your branch's commit history.&lt;/p&gt;

&lt;p&gt;In this case you wish to create new branch from last correct commit.&lt;/p&gt;

&lt;p&gt;The naive approach is to &lt;strong&gt;hard reset the branch to specific commit&lt;/strong&gt;, then create a new branch. 😏&lt;/p&gt;

&lt;p&gt;But hold on.... You can accomplish that &lt;strong&gt;without the resetting stuff&lt;/strong&gt;. 😎&lt;/p&gt;

&lt;p&gt;Voila!!&lt;/p&gt;

&lt;p&gt;Here are the steps :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;git log&lt;/code&gt; : &lt;strong&gt;Get the ID of commit&lt;/strong&gt; which you want to create new branch from.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute &lt;code&gt;git checkout -b &amp;lt;branch_name&amp;gt; &amp;lt;commit_id&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And there you go... 🎉&lt;/p&gt;

&lt;p&gt;Now you have created a new branch based of the &lt;code&gt;commit_id&lt;/code&gt; that was entered in the command.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>programming</category>
    </item>
    <item>
      <title>Microfrontend</title>
      <dc:creator>Tirth Patel</dc:creator>
      <pubDate>Mon, 27 Jun 2022 18:01:02 +0000</pubDate>
      <link>https://dev.to/tirthpatel/microfrontend-58ao</link>
      <guid>https://dev.to/tirthpatel/microfrontend-58ao</guid>
      <description>&lt;p&gt;&lt;strong&gt;Microfronted is such a fantastic concept that can revolutionize front-end development.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The new era of web development is heading towards micro frontends. It's like breaking the big stones from the mine into small diamonds. Tech giants like Google, Facebook, etc are using this architecture for many years.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
