<?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: FARHAN KHAN</title>
    <description>The latest articles on DEV Community by FARHAN KHAN (@itsfarhankhan28).</description>
    <link>https://dev.to/itsfarhankhan28</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%2F994551%2F34bcf597-cbae-4f66-9a2f-10e8a532aa45.jpeg</url>
      <title>DEV Community: FARHAN KHAN</title>
      <link>https://dev.to/itsfarhankhan28</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/itsfarhankhan28"/>
    <language>en</language>
    <item>
      <title>🚀Running Client and Server Together in MERN — No More “Oh, I Forgot to Start the Backend!” Moments</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Wed, 13 Aug 2025 21:21:55 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/running-client-and-server-together-in-mern-no-more-oh-i-forgot-to-start-the-backend-moments-3g8m</link>
      <guid>https://dev.to/itsfarhankhan28/running-client-and-server-together-in-mern-no-more-oh-i-forgot-to-start-the-backend-moments-3g8m</guid>
      <description>&lt;p&gt;When I was new to &lt;strong&gt;MERN stack development&lt;/strong&gt;, I faced this problem way too many times:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I’d open my project.&lt;/li&gt;
&lt;li&gt;I’d start the frontend (npm start inside the client folder).&lt;/li&gt;
&lt;li&gt;I’d forget to start the backend.&lt;/li&gt;
&lt;li&gt;Then I’d spend 10 minutes wondering why nothing was working… 😅&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’ve worked with MERN, you probably know the drill:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/
│── client/   # React frontend
│── server/   # Node.js backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We usually run them separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# In client folder
npm run dev

# In server folder
node server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means two terminals and remembering to start both every time.&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%2F2x0wcnzu8mfzx1i77bgo.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%2F2x0wcnzu8mfzx1i77bgo.png" alt=" " width="800" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 The Solution: Run Both Together with &lt;strong&gt;concurrently&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A few days ago, I found a simple way to avoid this hassle — &lt;strong&gt;run both with a single command.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install &lt;em&gt;concurrently&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;Go to your project root (the folder containing both &lt;strong&gt;client&lt;/strong&gt; and &lt;strong&gt;server&lt;/strong&gt;) and install:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Fgz20k0njx314m279ooyt.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%2Fgz20k0njx314m279ooyt.png" alt=" " width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Update &lt;em&gt;package.json&lt;/em&gt; in the root
&lt;/h3&gt;

&lt;p&gt;Inside your root &lt;strong&gt;package.json&lt;/strong&gt;, add a new script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "start": "concurrently \"npm start --prefix client\" \"npm run dev --prefix server\""
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what’s happening:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;npm start --prefix client&lt;/strong&gt; → runs the React app from the &lt;strong&gt;client&lt;/strong&gt; folder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm run dev --prefix server&lt;/strong&gt; → runs the backend from the &lt;strong&gt;server&lt;/strong&gt; folder (you can replace &lt;strong&gt;dev&lt;/strong&gt; with whatever script you use for backend).&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%2Fvm0jov10gxopnk7zk7za.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%2Fvm0jov10gxopnk7zk7za.png" alt=" " width="800" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Start both with one command
&lt;/h3&gt;

&lt;p&gt;Now you can simply run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;🎉 Both frontend and backend will start in the same terminal!&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%2F0th0pnavwt0ew9uzchi3.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%2F0th0pnavwt0ew9uzchi3.png" alt=" " width="800" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Love This
&lt;/h2&gt;

&lt;p&gt;✅ Beginner-friendly — No more “Oops, backend isn’t running.”&lt;br&gt;
✅ Cleaner workflow — One command, one terminal.&lt;br&gt;
✅ Easy to share — Anyone cloning your repo can run the project instantly.&lt;/p&gt;

&lt;p&gt;This might be a small trick, but it saved me time and frustration when I was starting out.&lt;br&gt;
If you’re new to MERN, give it a try — your future self will thank you! 🙌&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy coding!&lt;/strong&gt; 💻✨&lt;br&gt;
Have you used concurrently before, or do you have other tricks for running MERN smoothly? Share in the comments!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>mern</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Custom Inventory Management System Using VBA: A Cost-Effective Solution for Small Businesses</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Mon, 09 Dec 2024 05:35:18 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/custom-inventory-management-system-using-vba-a-cost-effective-solution-for-small-businesses-3oad</link>
      <guid>https://dev.to/itsfarhankhan28/custom-inventory-management-system-using-vba-a-cost-effective-solution-for-small-businesses-3oad</guid>
      <description>&lt;p&gt;Managing inventory efficiently is critical for businesses of any size. However, for small-scale businesses, investing in expensive CRM systems can often be overkill. This is where a custom inventory management system built with VBA (Visual Basic for Applications) comes into play as a simple, affordable, and effective solution.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The advantages of a VBA-based system.&lt;/li&gt;
&lt;li&gt;A practical example: WooCommerce and Excel integration using VBA.&lt;/li&gt;
&lt;li&gt;A sneak peek into the implementation details we’ll cover in Part 2.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Consider a Custom Inventory Management System?
&lt;/h2&gt;

&lt;p&gt;Small businesses often struggle with inventory management due to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Limited budgets for software solutions.&lt;/li&gt;
&lt;li&gt;The complexity of over-engineered CRM systems.&lt;/li&gt;
&lt;li&gt;The need for tailored solutions that align with their unique workflows.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A custom VBA-based inventory management system addresses these pain points by offering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cost Savings: VBA is included with Microsoft Office, making it virtually free for those who already use Excel.&lt;/li&gt;
&lt;li&gt;Customization: You can build a system tailored to your specific business needs, without unnecessary features.&lt;/li&gt;
&lt;li&gt;User-Friendliness: Since Excel is widely familiar, employees can quickly adapt to the system.&lt;/li&gt;
&lt;li&gt;Scalability for Growth: As your business expands, you can tweak the system to accommodate changing requirements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Real-World Use Case: WooCommerce and Excel with VBA
&lt;/h2&gt;

&lt;p&gt;One compelling use case of VBA for inventory management is integrating it with WooCommerce—a popular e-commerce platform. With VBA, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch product details directly from WooCommerce into Excel.&lt;/li&gt;
&lt;li&gt;Update inventory stock, prices, and product names by simply editing Excel sheets.&lt;/li&gt;
&lt;li&gt;Automatically synchronize updates with WooCommerce, reducing manual effort.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages of This Approach
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simplified Operations&lt;/strong&gt;
Using Excel as the interface eliminates the need to learn complex CRM dashboards.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Costs&lt;/strong&gt;
Unlike premium plugins or SaaS tools, this solution incurs no additional subscription costs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlined Updates&lt;/strong&gt;
For example, you can update the stock quantity for specific products without overwriting other details, making the system flexible for partial updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Productivity&lt;/strong&gt;
Automating inventory updates through VBA macros saves time, allowing your team to focus on core business activities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example Scenario: WooCommerce Inventory Update via Excel
&lt;/h2&gt;

&lt;p&gt;Imagine you’re running an online store with WooCommerce. Your inventory spreadsheet contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SKU (Stock Keeping Unit)&lt;/li&gt;
&lt;li&gt;Product name&lt;/li&gt;
&lt;li&gt;Stock quantity&lt;/li&gt;
&lt;li&gt;Price&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With VBA, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input changes in the stock quantity directly into the spreadsheet.&lt;/li&gt;
&lt;li&gt;Run a macro to update WooCommerce in real time.&lt;/li&gt;
&lt;li&gt;Receive a status column update (e.g., "Success" or "Error") for transparency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;In Part 2, we’ll dive into the technical implementation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up the WooCommerce REST API.&lt;/li&gt;
&lt;li&gt;Writing VBA macros to connect Excel with WooCommerce.&lt;/li&gt;
&lt;li&gt;Handling errors and testing the solution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This series is designed to empower small business owners and developers alike to build their own custom inventory management systems without breaking the bank.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A custom VBA inventory management system bridges the gap between functionality and affordability for small businesses. With tools you already use daily, such as Excel, you can create a robust solution that simplifies operations, reduces costs, and adapts to your business needs.&lt;/p&gt;

&lt;p&gt;Stay tuned for Part 2, where we’ll get our hands dirty with implementation!&lt;/p&gt;

</description>
      <category>vba</category>
      <category>woocommerce</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>Managing Multiple GitHub Accounts in VS Code: A Comprehensive Guide</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Sun, 28 Jul 2024 10:36:02 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/managing-multiple-github-accounts-in-vs-code-a-comprehensive-guide-2d5g</link>
      <guid>https://dev.to/itsfarhankhan28/managing-multiple-github-accounts-in-vs-code-a-comprehensive-guide-2d5g</guid>
      <description>&lt;p&gt;Now a days in this fast-paced development environment, it's common for developers to have multiple GitHub accounts. Whether you're working with different organizations, contributing to open-source projects, or maintaining personal repositories, having the ability to switch between accounts within a single instance of Visual Studio Code (VS Code) is invaluable. This guide will walk you through the process of setting up and managing multiple GitHub accounts in VS Code, ensuring you avoid common pitfalls and maintain a streamlined workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Setting Up SSH Keys
&lt;/h3&gt;

&lt;p&gt;To securely manage multiple GitHub accounts, you'll need to generate separate SSH keys for each account. This ensures that each account is uniquely identified and authenticated.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Generating SSH Keys:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Open your terminal and use the following command to generate a new SSH key. Replace &lt;em&gt;&lt;a href="mailto:your_email@example.com"&gt;your_email@example.com&lt;/a&gt;&lt;/em&gt; with the email associated with your GitHub account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll be prompted to save the key. For clarity, save it with a distinctive name like &lt;em&gt;key_work&lt;/em&gt; for your work account and &lt;em&gt;key_personal&lt;/em&gt; for your personal account.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Adding SSH Keys to GitHub:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next, add the generated SSH key to your GitHub account. Copy the public key using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ~/.ssh/id_rsa_work.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, navigate to GitHub, go to Settings -&amp;gt; SSH and GPG keys, and add the new key.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Configuring SSH for Multiple Accounts
&lt;/h3&gt;

&lt;p&gt;To handle multiple SSH keys, you need to configure your SSH client. Create or edit the &lt;em&gt;~/.ssh/config&lt;/em&gt; file and add entries for each account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Work GitHub account
Host github.com-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_work

# Personal GitHub account
Host github.com-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_personal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration tells your SSH client which key to use when connecting to GitHub.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Testing SSH Connections
&lt;/h3&gt;

&lt;p&gt;Verify that your SSH keys are correctly configured by testing the connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -T git@github.com-work
ssh -T git@github.com-personal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should receive a message confirming successful authentication for each account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Configuring Git Remotes in VS Code
&lt;/h3&gt;

&lt;p&gt;Now, you need to set up your Git remotes in your project repositories to use the correct SSH configurations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Adding Remotes:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In your project directory, add the appropriate remote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin git@github.com-work:username/work-repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the remote setup with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;Managing multiple GitHub accounts within a single instance of Visual Studio Code can greatly enhance your workflow, especially if you're juggling projects for different organizations or balancing professional and personal development work. By setting up distinct SSH keys for each account and configuring your SSH client properly, you can seamlessly switch between accounts without encountering permission errors or other common issues.&lt;/p&gt;

&lt;p&gt;The steps outlined in this guide—from generating SSH keys and configuring your SSH client, to adding and managing Git remotes—provide a robust framework for maintaining separate GitHub identities. This not only keeps your projects organized but also ensures a secure and efficient way to handle code repositories.&lt;/p&gt;

</description>
      <category>github</category>
      <category>vscode</category>
    </item>
    <item>
      <title>How to Deploy and Host Your Website Cost-Effectively with Vercel 💰💰</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Sun, 09 Jun 2024 14:57:37 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/how-to-deploy-and-host-your-website-cost-effectively-with-vercel-5ejk</link>
      <guid>https://dev.to/itsfarhankhan28/how-to-deploy-and-host-your-website-cost-effectively-with-vercel-5ejk</guid>
      <description>&lt;p&gt;Creating and deploying a portfolio website can often seem like a intimidating task, especially when you're trying to minimize costs without compromising on quality. Recently, I had the opportunity to develop a simple yet effective single-page portfolio for a client, and I found an efficient way to deploy it using Vercel while keeping expenses to a minimum.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717922315%2FBlog%2Ffojj2doxjsssw5uitaad.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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717922315%2FBlog%2Ffojj2doxjsssw5uitaad.png" title="Client's Portfolio" alt="Client's Portfolio"&gt;&lt;/a&gt;&lt;br&gt;
In this blog post, I'll share my experience and provide a step-by-step guide on how you can do the same for your projects, making use of cost-effective domain purchases and Vercel's hosting capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Behind the Scenes: Building a Sleek Single Page Portfolio
&lt;/h2&gt;

&lt;p&gt;The project at hand was a straightforward single-page portfolio designed to showcase the client's work. This portfolio was purely a frontend project, meaning there was no backend or database integration involved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Technologies Used:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Next.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Typescript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tailwind.css&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Development Highlights:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Responsive Design: Ensuring the portfolio looks great on all devices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interactive Elements: Adding smooth transitions and hover effects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clean Code: Keeping the codebase simple and maintainable.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Visual Guide: Deployment Process Simplified
&lt;/h2&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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717930659%2FBlog%2Fgt7p91r1p41pglzejqy7.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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717930659%2FBlog%2Fgt7p91r1p41pglzejqy7.png" title="Deployment Process" alt="Deployment Process"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment on Vercel
&lt;/h2&gt;

&lt;p&gt;Deploying the portfolio website was straightforward thanks to Vercel. Vercel is known for its simplicity and efficiency, making it an excellent choice for frontend projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Vercel?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ease of Use: Vercel provides a seamless deployment process, particularly for static sites.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Free Plan: Vercel's free tier is perfect for personal projects and small client projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic SSL: It automatically provides SSL certificates for your custom domains.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Steps to Deploy:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Sign Up and Set Up: Create a Vercel account and link it to your GitHub repository.&lt;/li&gt;
&lt;li&gt;Import Project: Import your project from GitHub, GitLab, or Bitbucket.&lt;/li&gt;
&lt;li&gt;Configure Settings: Set up the build settings if needed (though Vercel often auto-detects them).&lt;/li&gt;
&lt;li&gt;Deploy: Click the deploy button, and Vercel will handle the rest.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Acquiring and Pointing a Custom Domain
&lt;/h2&gt;

&lt;p&gt;After deploying the site on Vercel, the next step was to point a custom domain to it. I purchased a domain at a very affordable price from &lt;em&gt;&lt;strong&gt;HIOX India&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717936882%2FBlog%2Fpurxurt4ujoh0myzcckk.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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717936882%2FBlog%2Fpurxurt4ujoh0myzcckk.png" title="HIOX India" alt="HIOX India"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to Acquire and Point Domain:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Purchase Domain&lt;/li&gt;
&lt;li&gt;Access DNS Settings: Log into your domain registrar account and navigate to the DNS settings.&lt;/li&gt;
&lt;li&gt;Add DNS Records: Add an A record pointing to Vercel's IP address or use CNAME records as directed by Vercel.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Example of DNS Records:
&lt;/h3&gt;


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

&lt;p&gt;Type: A&lt;br&gt;
Name: @&lt;br&gt;
Value: 76.76.21.21 (Vercel's IP)&lt;/p&gt;

&lt;p&gt;Type: CNAME&lt;br&gt;
Name: www&lt;br&gt;
Value: cname.vercel-dns.com&lt;/p&gt;

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

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Screenshot of DNS Configuration:&lt;br&gt;
&lt;/h3&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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717937889%2FBlog%2Fw78ogi0fbeltepm6rmz7.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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717937889%2FBlog%2Fw78ogi0fbeltepm6rmz7.png" title="DNS configuration" alt="DNS configuration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717937982%2FBlog%2Firj9kafvwfxf94ylbzcc.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%2Fres.cloudinary.com%2Fdn2ljrxzy%2Fimage%2Fupload%2Fv1717937982%2FBlog%2Firj9kafvwfxf94ylbzcc.png" title="DNS configuration" alt="DNS configuration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost Efficiency
&lt;/h2&gt;

&lt;p&gt;One of the significant advantages of this deployment method is its cost efficiency. Here's how this approach helps in cutting costs:&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost Savings Breakdown:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Free Hosting: Vercel offers free hosting for static sites, reducing hosting expenses.&lt;/li&gt;
&lt;li&gt;Affordable Domains: Purchasing domains from budget-friendly registrars can save a considerable amount.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Overall Savings:
&lt;/h3&gt;

&lt;p&gt;By combining Vercel's free hosting with a cheap domain purchase, the total annual cost for maintaining the portfolio website was significantly reduced.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and Considerations
&lt;/h2&gt;

&lt;p&gt;While this approach is excellent for small projects, it's important to recognize its limitations:&lt;/p&gt;

&lt;h3&gt;
  
  
  Not Suitable for Larger Projects:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;No Backend Support: Vercel is ideal for frontend-only projects. Projects requiring server-side logic or database interactions need a different hosting solution.&lt;/li&gt;
&lt;li&gt;Limited Customization: Advanced server configurations are not possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples of Suitable Projects:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Portfolios&lt;/li&gt;
&lt;li&gt;Blogs&lt;/li&gt;
&lt;li&gt;Landing Pages&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Projects Requiring Alternative Solutions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;E-commerce Sites&lt;/li&gt;
&lt;li&gt;Web Applications with Backend&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In summary, deploying a single-page portfolio on Vercel while using an affordable custom domain is an excellent way to cut costs without sacrificing quality. This method is particularly suited for small to medium-sized projects where backend integration is not necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Vercel offers an easy and free hosting solution for static sites.&lt;/li&gt;
&lt;li&gt;Purchasing a domain from budget-friendly registrars can further reduce costs.&lt;/li&gt;
&lt;li&gt;This approach is ideal for portfolios, blogs, and landing pages, but not for projects requiring backend support.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Have you tried deploying a site using Vercel and a custom domain? Share your experiences and any tips you have in the comments below!
&lt;/h3&gt;

</description>
      <category>vercel</category>
      <category>deployment</category>
      <category>hosting</category>
      <category>website</category>
    </item>
    <item>
      <title>How to become an Astro developer.👨‍💻👨‍💻</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Thu, 29 Jun 2023 11:36:49 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/how-to-become-an-astro-developer-3cj2</link>
      <guid>https://dev.to/itsfarhankhan28/how-to-become-an-astro-developer-3cj2</guid>
      <description>&lt;p&gt;In this very tutorial we are going to look at why to use Astro to develop websites mostly content-focused websites such as marketing sites, publishing sites, documentation sites, blogs and even portfolios. &lt;/p&gt;

&lt;p&gt;Let's see some features of Astro that makes it a choice for web developers to built websites.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Fully-featured, but flexible&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can extend the features of Astro by integrating &lt;strong&gt;react&lt;/strong&gt; 
and &lt;strong&gt;tailwindcss&lt;/strong&gt; for easy styling. To know more about it 
visit to &lt;a href="https://docs.astro.build/en/concepts/why-astro/#fully-featured-but-flexible"&gt;astro-docs&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Easy to use&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As Astro contains the usage of HTML syntax it becomes very easy for developers to work with Astro. To Know more about it visit to &lt;a href="https://docs.astro.build/en/concepts/why-astro/#easy-to-use"&gt;astro-docs&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;You can see more features of Astro at&lt;/strong&gt; &lt;a href="https://docs.astro.build/en/concepts/why-astro/#overview"&gt;astro-features&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note that&lt;/strong&gt;-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No prerequisite is required as this tutorial is totally beginners friendly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Takeaways from this tutorial-
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;By the end of this tutorial, you will become an Astro developer which means that you will be able to create a simple static website using Astro.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Let's start creating the website using Astro-
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Installation&lt;/strong&gt;-

&lt;ul&gt;
&lt;li&gt;Get a new Astro project up and running locally using the following command-
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# create a new project with npm
npm create astro@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;After running the following command you will get the following msg. In that write the project name.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;You will get the following options after entering the name of the project. You can select anyone of the option according to you.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Next you will be asked whether to add dependency or not&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;You also get an option whether to use typescript or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hdX4dD01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70tq37010ygejvlfwjpl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hdX4dD01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70tq37010ygejvlfwjpl.png" alt="Image description" width="455" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also initialize a new git repository which makes your work one step simpler.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ol&gt;
&lt;li&gt;Running the app

&lt;ul&gt;
&lt;li&gt;Once the installation is completed you can go to the directory using the following command
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd myapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Once you are in the directory you can run your app locally using the following command
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;After running the following command you can see your app in the browser at URL- &lt;code&gt;http://localhost:3000&lt;/code&gt;. Your app should look somewhat like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7eP4xlkX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7k5vi17186erwzo5a9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7eP4xlkX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7k5vi17186erwzo5a9p.png" alt="Image description" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's take a quick peek at the folder structure- &lt;/p&gt;

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

&lt;p&gt;Now as you can see in the above image while working with Astro you have to use &lt;code&gt;.astro&lt;/code&gt; extensions for files. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;index.astro&lt;/code&gt; inside the &lt;code&gt;/src/pages&lt;/code&gt; directory is the root file. The changes that you make in the &lt;code&gt;index.astro&lt;/code&gt; file will get reflected in the browser.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ytWLWMWq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ee38wktxjij3otrf5sc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ytWLWMWq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ee38wktxjij3otrf5sc.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you reach this point you will become an Astro developer 🥳🥳🥳. Now you only have to make use of your frontend skills to improve the app.&lt;/p&gt;

&lt;p&gt;Additionally we can integrate tailwindcss with the Astro app by just running the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx astro add tailwind
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the above command you can easily use tailwindcss properties in the Astro app&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wanUF0Gn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3050dkihzakqyad28a56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wanUF0Gn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3050dkihzakqyad28a56.png" alt="Image description" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope that this tutorial is going to help the web developers to become an Astro developer.&lt;br&gt;
If someone have any doubt about this please leave a comment in the comment section, I will surely help.&lt;br&gt;
See you all in the next blog😊😊.&lt;/p&gt;

</description>
      <category>astro</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The easiest way of uploading image and audio files together using Multer, Cloudinary, and Node.js.</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Thu, 22 Jun 2023 13:28:13 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/the-easiest-way-of-uploading-image-and-audio-files-together-using-multer-cloudinary-and-nodejs-5ff3</link>
      <guid>https://dev.to/itsfarhankhan28/the-easiest-way-of-uploading-image-and-audio-files-together-using-multer-cloudinary-and-nodejs-5ff3</guid>
      <description>&lt;p&gt;The project list📃 of a backend web developer always includes projects on REST API and other websites projects such as E-commerce with fully functional backends. One main functionality of these kinds of projects is file uploading such as image, audio, video, etc. &lt;/p&gt;

&lt;p&gt;When working with MERN stack one of the most common and popular way of uploading a file is using-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.w3schools.com/nodejs/nodejs_intro.asp" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://expressjs.com/en/resources/middleware/multer.html#:~:text=Multer%20is%20a%20node.,multipart%2Fform%2Ddata%20" rel="noopener noreferrer"&gt;Multer&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cloudinary.com/documentation/node_quickstart" rel="noopener noreferrer"&gt;Cloudinary&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most probable solutions for uploading a file found on the internet are-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.geeksforgeeks.org/how-to-upload-single-multiple-image-to-cloudinary-using-node-js/" rel="noopener noreferrer"&gt;Uploading single or multiple image using multer, cloudinary and node.js&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloudinary.com/documentation/node_image_and_video_upload" rel="noopener noreferrer"&gt;Uploading an audio file using multer, cloudinary and node.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You have to search a lot to find the perfect solution for uploading the image and audio file together using multer, cloudinary and node.js.&lt;/p&gt;

&lt;p&gt;I hope that this blog of mine is going to help most of the backend web developers for easily uploading the image and the audio file together using multer, cloudinary and node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js and Express.js&lt;/li&gt;
&lt;li&gt;Multer&lt;/li&gt;
&lt;li&gt;Cloudinary&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Let us start with uploading the image and audio file
&lt;/h2&gt;

&lt;p&gt;First of all let's setup the express app. Following are the steps to create an express app. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a folder &lt;code&gt;server&lt;/code&gt; which contains a &lt;code&gt;server.js&lt;/code&gt; file which will be the root file. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the following command to initiate the node modules.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

npm init
npm i
npm i node-modules


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Install express using following command.&lt;/li&gt;
&lt;/ul&gt;

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

npm i express


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Setup the express app in the following way.&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%2F40adm59824jae2wft0ko.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%2F40adm59824jae2wft0ko.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the initial setup is done we will move further with the:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Addition of middlewares such as &lt;code&gt;app.use(express.json())&lt;/code&gt; and &lt;code&gt;app.use(express.urlencoded({extended: true}));&lt;/code&gt; and connection of mongodb using mongoose in &lt;code&gt;server.js&lt;/code&gt; file.&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%2Fk45653l15w5es701x1cs.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%2Fk45653l15w5es701x1cs.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the following way the routes setup is done.&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%2F7og8xfsdcne2f235dkdk.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%2F7og8xfsdcne2f235dkdk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now lets setup the Multer file which is in the middlware folder.&lt;/strong&gt;&lt;br&gt;
For uploading the image and audio file together we are going to use a third party dependency namely &lt;a href="https://www.npmjs.com/package/multer-storage-cloudinary" rel="noopener noreferrer"&gt;multer-storage-cloudinary&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the following way the multer setup is done using the third party dependency.&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%2F1ips7opiq39z2ajyvuny.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%2F1ips7opiq39z2ajyvuny.png" alt="Image description"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now we will use the &lt;code&gt;upload.fields&lt;/code&gt; as a middleware.&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%2F80lp17l4vko49i4sxa6q.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%2F80lp17l4vko49i4sxa6q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are also going to setup the cloudinary in the &lt;code&gt;cloudinaryconfig.js&lt;/code&gt; file so as to use it as a middleware in the &lt;code&gt;server.js&lt;/code&gt; file.&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%2F969eff5botukmjbiivzl.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%2F969eff5botukmjbiivzl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sd173tkll5hiabh7ux8.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%2F1sd173tkll5hiabh7ux8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the setup of Multer, Cloudinary is done we will take a quick peek of the &lt;code&gt;controller.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8pf2kfz719u1l1flxr6e.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%2F8pf2kfz719u1l1flxr6e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;uploadcontrol.js&lt;/code&gt; file:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First of all we have created an async function namely &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Then we have stored the path of both the image and the audio file in the constants &lt;strong&gt;imageurl&lt;/strong&gt; and &lt;strong&gt;audiourl&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the last step we have stored the value of both imageurl and audiourl in the &lt;strong&gt;Uploads&lt;/strong&gt; db.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the entire setup is done we will check the &lt;strong&gt;upload&lt;/strong&gt; request on &lt;strong&gt;Postman&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qi2imscymvi4p6afmbv.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%2F0qi2imscymvi4p6afmbv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hurrey!🥳🥳 we are successfully receiving the url of both the files.&lt;br&gt;
And also getting the url stored in mongodb.&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%2Fz0m07vy504g3voux0tbj.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%2Fz0m07vy504g3voux0tbj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I hope that this tutorial is going to help all the backend web developers out there in uploading the image and audio file together using Multer, Cloudinary and Node.js&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>multer</category>
      <category>cloudinary</category>
    </item>
    <item>
      <title>User authentication in MERN stack (Frontend and Backend connection)</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Wed, 14 Jun 2023 12:54:06 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-frontend-and-backend-connection-5fjb</link>
      <guid>https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-frontend-and-backend-connection-5fjb</guid>
      <description>&lt;p&gt;Throughout this informative journey of User authentication in MERN stack till now we have seen-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-part-1-4bj3"&gt;User authentication in MERN stack (Backend)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-frontend-1c14"&gt;User authentication in MERN stack (Frontend)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this tutorial we will be concentrating on the Frontend and the Backend connection.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We will take a closer look at the CORS error and also the solution for the same.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic understanding of &lt;strong&gt;form handling&lt;/strong&gt; in react.(&lt;a href="https://www.w3schools.com/react/react_forms.asp"&gt;Form handling&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  So lets begin with the connection.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Signup Form
&lt;/h3&gt;

&lt;p&gt;First of all we will create a function to handle the form on submit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q-XcnqyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chuik9h26of36fd1knor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q-XcnqyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chuik9h26of36fd1knor.png" alt="Image description" width="800" height="923"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this function-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First we are taking the values of all the fields.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then asynchronously using async and await we are setting up the fetch function where &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First parameter is the URL of the backend server.&lt;/li&gt;
&lt;li&gt;Then we specify the method i.e &lt;code&gt;method:"POST"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;After specifying the method we set the headers i.e &lt;code&gt;headers:{
    "Content-Type":"application/json"
}&lt;/code&gt; and send the content of the field in the string format 
using &lt;code&gt;body:JSON.stringify({
    username,  email , password , confirmpassword
})&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Once the function is completed we will call it from the Submit button using &lt;code&gt;onClick&lt;/code&gt;.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Login Form
&lt;/h3&gt;

&lt;p&gt;The setup of the function which handles the form on submit is similar to the signup form &lt;code&gt;onRegister&lt;/code&gt; function.&lt;/p&gt;

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

&lt;p&gt;And once the function setup is done we call the function in the submit button similar to signup form.&lt;/p&gt;

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

&lt;p&gt;Once the login and the signup form setup is completed the major part is handling the &lt;strong&gt;CORS&lt;/strong&gt; error.&lt;/p&gt;

&lt;p&gt;Now lets take a quick peek at the &lt;strong&gt;CORS&lt;/strong&gt; error:&lt;/p&gt;

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

&lt;p&gt;The CORS error can be solved by adding the &lt;strong&gt;Proxy server&lt;/strong&gt; in the &lt;code&gt;package.json&lt;/code&gt; file of the &lt;em&gt;Client side&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UHLMoKoc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ap8kiaamvf3edciubqm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UHLMoKoc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ap8kiaamvf3edciubqm.png" alt="Image description" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in this tutorial we have seen the connection of Frontend and Backend. We have covered -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The setup of the function that handles the login and the signup form on submit.&lt;/li&gt;
&lt;li&gt;The CORS error. Also the solution for the same.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this, we have completed the user authentication in MERN stack.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>User authentication in MERN stack (Frontend)</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Sun, 04 Jun 2023 14:49:33 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-frontend-1c14</link>
      <guid>https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-frontend-1c14</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-part-1-4bj3"&gt;User authentication in MERN stack (Backend)&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before starting with this tutorial we will take a quick peek at what we saw in the last tutorial&lt;/p&gt;

&lt;p&gt;In the last tutorial, we covered the backend logic of Signup and Login. We saw-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Folder structure for Backend 📂&lt;/li&gt;
&lt;li&gt;Concept of Server.js file where the express app was defined.&lt;/li&gt;
&lt;li&gt;Building of Schema.&lt;/li&gt;
&lt;li&gt;Routes of Login and Signup.&lt;/li&gt;
&lt;li&gt;Controllers that contain the Signup and Login logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What are we expecting from this tutorial?
&lt;/h3&gt;

&lt;p&gt;In this tutorial, we will take a deep dive into the frontend of user authentication which contains the login and signup form.&lt;/p&gt;

&lt;p&gt;The takeaway points from this tutorial are-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to create a react app using &lt;strong&gt;Vite&lt;/strong&gt; rather than &lt;strong&gt;CRA(create-react-app).&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;How to set up the Login and Signup form.&lt;/li&gt;
&lt;li&gt;How to set up Router.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A basic understanding of React. &lt;a href="https://www.w3schools.com/whatis/whatis_react.asp" rel="noopener noreferrer"&gt;(React)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;How Components and Pages are created in react. &lt;a href="https://www.w3schools.com/react/react_components.asp#:~:text=Components%20are%20independent%20and%20reusable,will%20concentrate%20on%20Function%20components." rel="noopener noreferrer"&gt;(Components in React)&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Folder Structure
&lt;/h2&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%2Fj31v54c0gdor84l0r11h.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%2Fj31v54c0gdor84l0r11h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image gives a glimpse of what the folder structure of the frontend consists of. It consists of -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Assets folder&lt;/strong&gt;📂 - It consists of &lt;code&gt;Images folder&lt;/code&gt; where all images are stored&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Components folder&lt;/strong&gt;📂 - It consists of &lt;code&gt;Navbar.jsx&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pages folder&lt;/strong&gt;📂 - It consists of &lt;code&gt;Login.jsx&lt;/code&gt; and &lt;code&gt;Signup.jsx&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other files - App.css, App.jsx, main.jsx, index.css.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up the react app with Vite
&lt;/h2&gt;

&lt;p&gt;At this point, a fascinating query may arise if we already have &lt;strong&gt;CRA&lt;/strong&gt; to create a react app then why use &lt;strong&gt;Vite&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/a5viI92PAF89q/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/a5viI92PAF89q/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a simpler answer to that&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Vite uses the esbuild bundler, which is much faster than the Webpack used in CRA.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, we can say that a React app can be built faster using Vite as compared to CRA.&lt;/p&gt;

&lt;h4&gt;
  
  
  the Following command is used to create React app using Vite
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;npm create vite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the above command &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Enter the &lt;em&gt;project name&lt;/em&gt; .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;em&gt;framework&lt;/em&gt; you want to work with.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the variant for eg- &lt;strong&gt;Javascript&lt;/strong&gt; or &lt;strong&gt;Typescript&lt;/strong&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Components
&lt;/h2&gt;

&lt;p&gt;Before starting with &lt;code&gt;Navbar. jsx&lt;/code&gt; which is a component let's see a short description of what are &lt;strong&gt;Components&lt;/strong&gt; in react&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Navbar.jsx
&lt;/h3&gt;

&lt;p&gt;As per the definition of components which says that components are &lt;em&gt;reusable bits of code&lt;/em&gt; hence the &lt;code&gt;Navbar.jsx&lt;/code&gt; is created as a component we do not have to write its code for all pages.&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%2Fek04i6zxwdicrg2ys76e.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%2Fek04i6zxwdicrg2ys76e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxpcwfvrgpblj5orgorzp.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%2Fxpcwfvrgpblj5orgorzp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pages
&lt;/h2&gt;

&lt;p&gt;Both the Signup and Login page are created using &lt;strong&gt;Ant Design&lt;/strong&gt;. To make development more faster you can use either &lt;em&gt;Material UI&lt;/em&gt; or &lt;em&gt;Ant Design&lt;/em&gt; .&lt;/p&gt;

&lt;p&gt;Let's take a quick peek at what is Ant Design.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Ant Design is an open-source design system developed by the Ant Group–parent company of Alibaba, Alipay, Huabei, and MYbank, to name a few.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Signup.jsx
&lt;/h3&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%2F7nxdedaey58q324hghzb.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%2F7nxdedaey58q324hghzb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Starting with the Signup form first of all we import all necessary components required for the form from &lt;code&gt;antd&lt;/code&gt;. &lt;br&gt;
Then for the better understanding of the form fields we import all necessary icons from &lt;code&gt;@ant-design/icons&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78e97alklugqj15rj2u1.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%2F78e97alklugqj15rj2u1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglvcxh0wm4qy2qucc5vt.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%2Fglvcxh0wm4qy2qucc5vt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once all necessary components and icons are imported we set up the form by adding &lt;strong&gt;username&lt;/strong&gt;, &lt;strong&gt;email&lt;/strong&gt;, &lt;strong&gt;password&lt;/strong&gt; and &lt;strong&gt;confirm password&lt;/strong&gt; fields and applying the operations of each field provided by Ant Design.&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%2Fp88w6ls4nd9g8oxjlrc4.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%2Fp88w6ls4nd9g8oxjlrc4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Login.jsx
&lt;/h3&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%2Fav7i90xhuo234jkujg37.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%2Fav7i90xhuo234jkujg37.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similar to Signup form in the Login form also we first of all import all necessary components and icons.&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%2Fice8vgudbhjhz9nddfpo.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%2Fice8vgudbhjhz9nddfpo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Login Form is also set up by adding the email and password field and applying their operation provided by Ant design.&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%2Fvy0hpfi4xlf75o7hgka3.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%2Fvy0hpfi4xlf75o7hgka3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Router Setup
&lt;/h2&gt;

&lt;p&gt;To link the pages with each other in react we use &lt;strong&gt;react-router&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let us first have a look at what is &lt;strong&gt;react-router&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;React Router is a JavaScript framework that lets us handle client and server-side routing in React applications. It enables the creation of single-page web or mobile apps that allow navigating without refreshing the page&lt;/em&gt; .&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;First of all install the react-router from following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i react-router-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fxd0ijgtj9pfjq0graour.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%2Fxd0ijgtj9pfjq0graour.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Starting with the router setup-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First import all the pages that are homepage, login, signup.&lt;/li&gt;
&lt;li&gt;Import &lt;strong&gt;createBrowserRouter&lt;/strong&gt; and &lt;strong&gt;RouterProvider&lt;/strong&gt; from &lt;code&gt;react-router-dom&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Then using &lt;code&gt;createBrowserRouter&lt;/code&gt; create the array of &lt;em&gt;paths&lt;/em&gt; and &lt;em&gt;elements&lt;/em&gt; and assign it to the &lt;strong&gt;router&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Configure the route using &lt;code&gt;RouterProvider&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, In this tutorial we saw -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Folder structure of frontend 📂.&lt;/li&gt;
&lt;li&gt;Creating react app with Vite.&lt;/li&gt;
&lt;li&gt;Components and Pages.&lt;/li&gt;
&lt;li&gt;Creating Router.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned for next tutorial of User authentication with MERN. As in the next tutorial we are going to focus on the connection of frontend and backend. See you all in the next tutorial.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>User authentication in MERN stack (Backend)</title>
      <dc:creator>FARHAN KHAN</dc:creator>
      <pubDate>Mon, 22 May 2023 21:41:30 +0000</pubDate>
      <link>https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-part-1-4bj3</link>
      <guid>https://dev.to/itsfarhankhan28/user-authentication-in-mern-stack-part-1-4bj3</guid>
      <description>&lt;p&gt;In this tutorial, we will dive into the fundamentals of user authentication, covering key concepts such as registration, login, password hashing. It will guide you through the process of setting up a secure authentication system, from building the backend API using Node.js and Express.js to creating a user-friendly frontend with React.&lt;/p&gt;

&lt;p&gt;Whether you are a beginner looking to gain a solid foundation in user authentication or an experienced developer seeking to enhance your skills with the MERN stack, this tutorial will provide you with the knowledge and tools necessary to implement robust user authentication in your web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.w3schools.com/nodejs/nodejs_intro.asp" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/express-js/" rel="noopener noreferrer"&gt;Express.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.mongodb.com/what-is-mongodb" rel="noopener noreferrer"&gt;MongoDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.postman.com/product/what-is-postman/" rel="noopener noreferrer"&gt;Postman&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Folder Structure
&lt;/h2&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%2Fo7x3mci8hz4o2v74i1ot.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%2Fo7x3mci8hz4o2v74i1ot.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The folder structure for user authentication of &lt;strong&gt;mern&lt;/strong&gt; website  contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A &lt;code&gt;server.js&lt;/code&gt; file - where the main express app is initiated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;code&gt;model folder&lt;/code&gt; - which contains all &lt;em&gt;mongodb documents Schema files&lt;/em&gt; in which the &lt;em&gt;documents  schemas&lt;/em&gt; are defined.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;code&gt;router folder&lt;/code&gt; - which contains all route files where  &lt;em&gt;routes are defined&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;code&gt;controllers folder&lt;/code&gt; - which contains all controller files where the &lt;em&gt;authentication logic is written&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Server.js
&lt;/h3&gt;

&lt;p&gt;As mentioned above in &lt;code&gt;server.js&lt;/code&gt; file the express app is initiated.&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%2Fudow555w46r9hd9ia0gw.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%2Fudow555w46r9hd9ia0gw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To start with the &lt;code&gt;server.js&lt;/code&gt; we first of all need to import all necessary dependencies such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/introduction-to-mongoose-for-mongodb-d2a7aa593c57/" rel="noopener noreferrer"&gt;mongoose&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/express-js/" rel="noopener noreferrer"&gt;express&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" rel="noopener noreferrer"&gt;cors&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/body-parser-middleware-in-node-js/" rel="noopener noreferrer"&gt;body-parser&lt;/a&gt;&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%2Fb73nzce9sbz9t9d57w2q.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%2Fb73nzce9sbz9t9d57w2q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After importing all the necessary dependencies we have used &lt;em&gt;middleware&lt;/em&gt; such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;app.use(bodyParser.urlencoded({ extended: true }))&lt;/code&gt; - to parse URL encoded data &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;app.use(bodyParser.json())&lt;/code&gt; - to parse json data.&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%2Fp0kz8i8xs5t366gaswgv.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%2Fp0kz8i8xs5t366gaswgv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have also created post request for &lt;em&gt;api/podcasts,login,signup&lt;/em&gt;. &lt;br&gt;
After that we have made connection with mongoDB database &lt;em&gt;(cloud i.e atlas or compass)&lt;/em&gt; .&lt;/p&gt;

&lt;h3&gt;
  
  
  userSchema.js
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;userSchema.js&lt;/code&gt; file is in the &lt;em&gt;models folder&lt;/em&gt; where the schema for user authentication is defined.&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%2F66evpldt50zsjc0hrj1q.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%2F66evpldt50zsjc0hrj1q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;userSchema.js&lt;/code&gt; first of all we import &lt;em&gt;mongoose&lt;/em&gt; which is used to create the schema. Then we create the schema having fields username, email, password and confirmpassword.&lt;/p&gt;

&lt;h3&gt;
  
  
  user.js
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;user.js&lt;/code&gt; file is inside the &lt;em&gt;routes folder&lt;/em&gt; where routers for login and signup are defined.&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%2Fsub633b6dmnku25tpr57.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%2Fsub633b6dmnku25tpr57.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;user.js&lt;/code&gt; first of all we import express which is required for creating routes. Then we import the login and signup controllers from &lt;code&gt;Usercontroller.js&lt;/code&gt;. Then we create router using &lt;code&gt;express.Router()&lt;/code&gt;. After that we create routers for login and signup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usercontroller.js
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Usercontroller.js&lt;/code&gt; file in &lt;em&gt;controllers folder&lt;/em&gt; contains the logic of login and signup.&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%2Fpu5egemjqylhvpcq3f9w.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%2Fpu5egemjqylhvpcq3f9w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To start with the user controller we first of all import all necessary dependencies such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://jwt.io/introduction" rel="noopener noreferrer"&gt;jwt&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/jyeett/what-is-bcrypt-and-why-2dd1"&gt;bcrypt&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Signup Logic
&lt;/h4&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%2Fp1cogaa7irhyb3ctjis1.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%2Fp1cogaa7irhyb3ctjis1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the values of field such as username, email, password and confirmpassword using &lt;code&gt;req.body&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Check for the empty fields.&lt;/li&gt;
&lt;li&gt;If any empty field is present throw error &lt;code&gt;('Please fill the field')&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Check whether the entered email by the user is present in the databse or not.&lt;/li&gt;
&lt;li&gt;If the entered email is already present in the database than return &lt;code&gt;res.status(400).json('Email already exist')&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;If the entered email is not present in the database than create the instance of the schema model and pass the new values.
&lt;code&gt;const user = new User({
                username:username,
                email:email,
                password:password,
                confirmpassword:confirmpassword
            })&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create the salt value using &lt;code&gt;await  bcrypt.genSalt(10)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Then we create hash value using &lt;code&gt;await bcrypt.hash(password,salt)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Once the hash value is created we store it as the user password &lt;code&gt;user.password = hash&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;After that we save the instance of the schema &lt;code&gt;user.save()&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Login Logic
&lt;/h4&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%2F6n3qjkq9gq1gx0jcvoob.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%2F6n3qjkq9gq1gx0jcvoob.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For the login we first get the values of fields using &lt;code&gt;req.body&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check for the empty fields&lt;/li&gt;
&lt;li&gt;if any empty field is present than throw error &lt;code&gt;('Please fill the field')&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check if the entered email by the user is present in the database or not.&lt;/li&gt;
&lt;li&gt;If the entered email is not present than throw err &lt;code&gt;return res.status(404).json({error:"User not found"})&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If the entered email is present than compare the entered password and the hash password using &lt;code&gt;bcrypt.compare&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&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%2Frkegeqw5ktc4ff790zv8.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%2Frkegeqw5ktc4ff790zv8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in this tutorial we have covered the backend part of user authentication in MERN where we have seen the folder structure of the backend, also Schema for document, routes and controllers(logic of Signup and login).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the second part of this blog we are going to see frontend and the backend connection.&lt;/strong&gt;&lt;/p&gt;

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