DEV Community

Cover image for How to deploy react app
sahil singh
sahil singh

Posted on • Updated on

How to deploy react app

To deploy a React app to Netlify, you can follow these steps:

Build your React app:

Before deploying, you need to create a production-ready build of your React app. Open a terminal or command prompt, navigate to your project's directory, and run the following command:

npm run build
Enter fullscreen mode Exit fullscreen mode

This will generate an optimized build of your React app in a build directory

Sign up for Netlify:

If you haven't already, go to the Netlify website https://www.netlify.com
and sign up for a free account. Once you've signed up and logged in, you'll be taken to the Netlify dashboard.

Create a new site:

On the Netlify dashboard, click on the "New site from Git" button. Choose the Git provider where your project is hosted (e.g., GitHub, GitLab, Bitbucket) and connect to your repository.

Configure your site settings:

After connecting your repository, Netlify will automatically detect your build settings. Verify that the "Build command" field contains the correct build command for your project (usually npm run build). In the "Publish directory" field, enter build to specify that Netlify should use the contents of the build directory.

Customize your build settings (optional):

Netlify provides various build settings and deployment configurations. You can customize these settings based on your project's requirements. For example, you can set environment variables, specify redirects or rewrite rules, and configure form handling.

Deploy your app:

Once you've configured your site settings, click on the "Deploy site" button. Netlify will initiate the build process by pulling your code from the connected repository, running the build command, and deploying the optimized build to their global CDN (Content Delivery Network).

Wait for deployment:

Netlify will show the build progress and deployment logs in the deployment panel. Once the deployment is complete, you'll be provided with a unique URL for your deployed app.

Test your app:

Visit the provided URL to see your React app live on the web. Netlify also provides automatic continuous deployment, so any future changes pushed to your repository will trigger new builds and updates to your deployed app.

That's it! Your React app is now deployed on Netlify. You can further explore Netlify's features like custom domains, SSL certificates, and form handling to enhance your app deployment experience.

Top comments (0)