<?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: Parshi Praneesh</title>
    <description>The latest articles on DEV Community by Parshi Praneesh (@ppraneesh).</description>
    <link>https://dev.to/ppraneesh</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%2F1406318%2F300da43e-57b2-462f-b094-32283bbe21ad.jpeg</url>
      <title>DEV Community: Parshi Praneesh</title>
      <link>https://dev.to/ppraneesh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ppraneesh"/>
    <language>en</language>
    <item>
      <title>Deploy react, node projects for free on vercel</title>
      <dc:creator>Parshi Praneesh</dc:creator>
      <pubDate>Mon, 17 Jun 2024 15:20:38 +0000</pubDate>
      <link>https://dev.to/ppraneesh/deploy-react-node-projects-for-free-on-vercel-4365</link>
      <guid>https://dev.to/ppraneesh/deploy-react-node-projects-for-free-on-vercel-4365</guid>
      <description>&lt;p&gt;Looking to deploy your projects without spending a dime? You've come to the right place. There are several platforms out there that offer free deployment with some resource limitations. Some of the options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Pages&lt;/li&gt;
&lt;li&gt;Glitch&lt;/li&gt;
&lt;li&gt;Render&lt;/li&gt;
&lt;li&gt;Netlify&lt;/li&gt;
&lt;li&gt;Vercel&lt;/li&gt;
&lt;li&gt;Digital Ocean&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Among these, I find Vercel to be the best for hobby projects. It's free, even for backend applications, and it boasts a 99% uptime. I was pleasantly surprised when my Node and Flask applications worked seamlessly on Vercel. In this blog, I'll show you how to deploy a frontend (React.js), a Node.js backend, and even connect MongoDB to your backend.&lt;/p&gt;




&lt;h3&gt;
  
  
  Deploying React.js with Vercel
&lt;/h3&gt;

&lt;p&gt;Let's start with deploying a React.js application. I used Vite to create my React apps. If you haven't used it before, don't worry; it's straightforward. Here's a step-by-step guide:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Upload Your Project to GitHub
Make sure your project is uploaded to your GitHub account.&lt;/li&gt;
&lt;li&gt;Create a Vercel Account
Sign up for a Vercel account using your GitHub credentials.&lt;/li&gt;
&lt;li&gt;Add a New Project on Vercel&lt;/li&gt;
&lt;li&gt;Click on the "Add New" button (top right, white color).&lt;/li&gt;
&lt;li&gt;Connect your GitHub account.&lt;/li&gt;
&lt;li&gt;Choose the repository you want to deploy.&lt;/li&gt;
&lt;li&gt;Type in your project name.&lt;/li&gt;
&lt;li&gt;Select the root directory (where your React files are located, e.g., frontend/reactfile/).&lt;/li&gt;
&lt;li&gt;Hit deploy.&lt;/li&gt;
&lt;li&gt;And that's it! Your project will be deployed, and you'll get a URL ending with vercel.app.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Deploying Node.js with Vercel
&lt;/h3&gt;

&lt;p&gt;Deploying a Node.js application is a bit more involved, but don't worry, I've got you covered. Follow these steps carefully:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a directory named 'api' in your project folder.&lt;/li&gt;
&lt;li&gt;Place your main server logic in index.js inside the /api directory. &lt;/li&gt;
&lt;li&gt;Organize Additional Files&lt;/li&gt;
&lt;li&gt;If you have additional server files (e.g., teacherAPI.js), place them in the /api directory.&lt;/li&gt;
&lt;li&gt;Ensure Correct File Placement: Make sure package.json, package-lock.json, and .gitignore are outside the /api directory.&lt;/li&gt;
&lt;li&gt;Create vercel.json: In your project folder, create a file named vercel.json and paste the following content:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"version": 2,
"rewrites": [
    {
    "source": "/(.*)",
    "destination": "/api"
    }  
]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Commit your changes and push your project to GitHub.&lt;/li&gt;
&lt;li&gt;Deploy on Vercel: Go to Vercel and click "Add New" and select your repository.&lt;/li&gt;
&lt;li&gt;Set the framework preset to "Other."&lt;/li&gt;
&lt;li&gt;Ensure your root directory contains /api, .gitignore, package.json, etc.&lt;/li&gt;
&lt;li&gt;Copy your .env file content and paste it into the environment variables section on Vercel.&lt;/li&gt;
&lt;li&gt;Hit Deploy and voila! Your Node.js application is now deployed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;File Structure for Node.js Backend&lt;br&gt;
Here's a visual representation of the file structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root directory
    |___
        |_ api
        |     |_ index.js
        |     |_ middlewares
        |_ package.json
        |_ .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Connecting MongoDB to Your Node Server
&lt;/h3&gt;

&lt;p&gt;If you're using MongoDB with your Node server, you'll need to configure Vercel a bit differently. However, I've encountered issues with MongoDB disconnecting after a while. I recommend using Firebase instead, which is as simple as MongoDB and more stable for this setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;I hope this guide helps you deploy your projects easily and efficiently. Experiment, learn, and happy coding!&lt;br&gt;
Feel free to reach out if you have any questions or need further assistance. Keep experimenting and keep coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>deployment</category>
    </item>
  </channel>
</rss>
