Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 6204

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 60k
Author
Asked: November 27, 20242024-11-27T04:22:08+00:00 2024-11-27T04:22:08+00:00

Deploy react, node projects for free on vercel

  • 60k

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:

  • GitHub Pages
  • Glitch
  • Render
  • Netlify
  • Vercel
  • Digital Ocean

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.


Deploying React.js with Vercel

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:

  1. Upload Your Project to GitHub Make sure your project is uploaded to your GitHub account.
  2. Create a Vercel Account Sign up for a Vercel account using your GitHub credentials.
  3. Add a New Project on Vercel
  4. Click on the “Add New” button (top right, white color).
  5. Connect your GitHub account.
  6. Choose the repository you want to deploy.
  7. Type in your project name.
  8. Select the root directory (where your React files are located, e.g., frontend/reactfile/).
  9. Hit deploy.
  10. And that's it! Your project will be deployed, and you'll get a URL ending with vercel.app.

Deploying Node.js with Vercel

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

  1. Create a directory named 'api' in your project folder.
  2. Place your main server logic in index.js inside the /api directory.
  3. Organize Additional Files
  4. If you have additional server files (e.g., teacherAPI.js), place them in the /api directory.
  5. Ensure Correct File Placement: Make sure package.json, package-lock.json, and .gitignore are outside the /api directory.
  6. Create vercel.json: In your project folder, create a file named vercel.json and paste the following content:
{ "version": 2, "rewrites": [     {     "source": "/(.*)",     "destination": "/api"     }   ] } 
Enter fullscreen mode Exit fullscreen mode

  1. Commit your changes and push your project to GitHub.
  2. Deploy on Vercel: Go to Vercel and click “Add New” and select your repository.
  3. Set the framework preset to “Other.”
  4. Ensure your root directory contains /api, .gitignore, package.json, etc.
  5. Copy your .env file content and paste it into the environment variables section on Vercel.
  6. Hit Deploy and voila! Your Node.js application is now deployed.

File Structure for Node.js Backend
Here's a visual representation of the file structure:

root directory     |___         |_ api         |     |_ index.js         |     |_ middlewares         |_ package.json         |_ .gitignore 
Enter fullscreen mode Exit fullscreen mode


Connecting MongoDB to Your Node Server

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.

Final Thoughts

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

beginnersdeploymentwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers
  • Author

    Refactoring for Efficiency: Tackling Performance Issues in Data-Heavy Pages

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.