REACT Deploy (Vercel/Netlify)

Deploying React applications to modern platforms like Vercel and Netlify is quick and easy. Both platforms provide seamless integrations, automatic builds, and continuous deployment from your Git repository.

1. Deploying to Vercel

Vercel is a popular hosting platform designed for frontend frameworks like React. Follow these steps to deploy your React app:

Step 1: Install Vercel CLI (Optional)

If you want to deploy via the CLI, install the Vercel CLI globally:

npm install -g vercel

Try It Now

Step 2: Push Your Code to GitHub

  1. Make sure your React app code is pushed to a GitHub, GitLab, or Bitbucket repository.
  2. Ensure the repository contains the production build (npm run build is handled automatically by Vercel).

Step 3: Deploy via Vercel Dashboard

  1. Go to Vercel Dashboard.
  2. Click “New Project” and import your React app repository.
  3. Configure build settings:
    • Build Command: npm run build
    • Output Directory: build
  4. Click Deploy. Vercel will build and deploy your React app.

Step 4: Access Your Deployed App

Once deployment is complete, Vercel provides a live URL for your app. For example:

Optional: Deploy Using the CLI

  1. Run the following command in your React project directory:
    vercel
    

    Try It Now

  2. Follow the prompts to deploy your app.

 

2. Deploying to Netlify

Netlify is another excellent platform for hosting React applications. Here’s how you can deploy:

Step 1: Push Your Code to GitHub

Make sure your React app is pushed to a GitHub repository.

Step 2: Build Your React App

If you want to preview or manually deploy, first create a production build locally:

npm run build

Try It Now

Step 3: Deploy via Netlify Dashboard

  1. Go to Netlify Dashboard.
  2. Click “Add New Site” > “Import an Existing Project”.
  3. Choose your GitHub repository.
  4. Configure build settings:
    • Build Command: npm run build
    • Publish Directory: build
  5. Click Deploy Site.

Step 4: Access Your Deployed App

After deployment, Netlify provides a live URL for your app. For example:

https://your-app-name.netlify.app

Try It Now

Optional: Deploy Using Drag-and-Drop

  1. Create a production build locally:
    npm run build
    

    Try It Now

  2. Drag and drop the build/ folder onto the Netlify Drop Zone: Netlify Drop.

 

3. Comparison Between Vercel and Netlify

Feature Vercel Netlify
Ease of Use Extremely intuitive Extremely intuitive
Build Settings Auto-detects React apps Auto-detects React apps
Global CDN Yes Yes
Free Custom Domain Yes Yes
Deploy Previews Yes Yes
Serverless Functions Built-in Built-in
Edge Functions Yes Yes
Performance Optimization Excellent Excellent

4. Environment Variables

Both Vercel and Netlify allow you to define environment variables for sensitive data like API keys.

In Vercel:

  1. Go to your project in the Vercel dashboard.
  2. Navigate to Settings > Environment Variables.
  3. Add your variables (e.g., REACT_APP_API_URL) and redeploy.

In Netlify:

  1. Go to your project in the Netlify dashboard.
  2. Navigate to Site Settings > Environment Variables.
  3. Add your variables (e.g., REACT_APP_API_URL) and redeploy.

5. Custom Domains

Both platforms allow you to add custom domains to your app.

In Vercel:

  1. Go to your project in the Vercel dashboard.
  2. Navigate to Settings > Domains and add your custom domain.
  3. Update DNS records with your domain registrar.

In Netlify:

  1. Go to your project in the Netlify dashboard.
  2. Navigate to Domain Management and add your custom domain.
  3. Update DNS records with your domain registrar.

6. Continuous Deployment

Both platforms provide continuous deployment:

  • When you push changes to your Git repository, the app will automatically rebuild and redeploy.
  • Great for teams working collaboratively.

Summary

Task Vercel Command/Step Netlify Command/Step
Install CLI npm install -g vercel No CLI needed for basic drag/drop
Build Command npm run build (auto-detected) npm run build (auto-detected)
Publish Directory build build
Dashboard Deploy Use Vercel Dashboard Use Netlify Dashboard
Production URL vercel.app netlify.app