Skip to main content

Command Palette

Search for a command to run...

Comprehensive Guide to Host React website on Vercel

Published
5 min read
Comprehensive Guide to Host React website on Vercel

Introduction to React

What is React?

React is a popular JavaScript library for building dynamic and interactive user interfaces. Developed and maintained by Facebook, React has revolutionized web development by introducing a component-based architecture. This approach allows developers to break down their user interfaces into reusable, self-contained components, making code more modular and maintainable.

React's virtual DOM efficiently updates only the parts of a web page that change, resulting in fast and responsive applications. It supports unidirectional data flow, making it easier to manage application state and update UI components.

One of React's standout features is its strong developer community and extensive ecosystem of libraries and tools, such as Redux for state management and React Router for navigation. Additionally, it is compatible with server-side rendering, making it ideal for creating SEO-friendly web applications.

React has been adopted by numerous companies and is a valuable skill for web developers, enabling them to create modern, efficient, and visually appealing web applications.

Getting started with React can seem overwhelming, but fear not! Let's break it down into simple steps.

Prerequisites for React App

Before we dive into building a React application, make sure you have the following:

  • Basic understanding of HTML, CSS and JavaScript: Having a solid grasp of fundamental web development concepts like HTML, CSS, and JavaScript provides a strong foundation for learning React.

  • Setting up the Environment To get started with React, you'll need to set up your development environment.

    Here's a step-by-step guide:

    • Install Node.js and npm: These are essential tools for setting up and managing your React project.

      Visit the Node.js website and download the latest version of Node.js for your operating system. The installation process is typically straightforward, so follow the prompts to install Node.js and npm.

Create a New React Application

Open your terminal or command prompt and run the following command to create a new React application:

npx create-react-app vercel-deploy-demo

Replace "vertical-deploy-demo" with the name you want for your application. This command sets up a new React project with all the necessary files and configurations.

Navigate to Your Project

Switch to the directory of your React application project by running the command

cd vercel-deploy-demo

Start the Development Server

To see your React application in action, run the following command:

npm run

This command starts the development server and opens your React application in a web browser.

Creating a React Component

In React, we organize our application into reusable components. Let's create a simple component to display our greeting.

Open your favorite code editor and follow these steps:

Create a New React Component File: Inside your React project folder (where you ran npx create-react-app my-react-app), navigate to thesrc folder and create a new file called HelloPeople.js.

Edit the Component File: Open HelloPeople.js and add the following code:

this code, we define a functional component called HelloPeople. This component returns a simple div containing our greeting and for styling imported another file HelloPeople.css file

Now that we have our component, let's use it in our application.

Modify App.js: Open src/App.js and import our HelloPeople component:

Here, we import the HelloPeople component and use it within our App component.

Running the Application

Save your changes and run your React application using npm start. Open your browser and go to http://localhost:3000.

You should see "Hello People 👋..!" displayed on the page.

Deploying your React App on Vercel

Before hosting the react app, we need to create a github repository which will be connected to the vercel.

Create a new Repository

Run the following commands to connect your local project to the GitHub repository you just created:

Make Your Work Live!

Greetings, fellow coder! In our previous guides, we ventured into the world of React, creating our first " Hello People👋...!" application. Now, let's take it a step further and bring our creation to life on the web using Vercel!

What is Vercel?

Vercel is a fantastic platform that allows you to deploy web projects quickly. It's intuitive, reliable, and offers a seamless deployment process, making it a popular choice among developers.

Vercel is a fantastic platform that allows developers to effortlessly deploy web applications, making them accessible on the internet. Whether you've built a static website or a dynamic web app, Vercel simplifies the deployment process. It's known for its user-friendly interface and speedy deployments. Vercel supports various frontend frameworks like React, Angular, Vue.js, and more, making it versatile and widely adopted within the developer community.

To begin, let's walk through the necessary steps.

Steps

  1. React Application: Ensure you have a React application ready to be deployed.

  2. Vercel Account: Sign up for a Vercel account if you haven't created an account on Vercel.

If you have already created an account then Login using GitHub, GitLab, Bitbucket or simply continue with Email

After successfully logging in or signing up, you will be redirected to the vercel-dashboard

Deploying Your React App on Vercel

Now let's get started with the deployment process!

Search for your git repository which you wanted to host

Import the selected repository

If your repository is not listed then to continue, click on Configure GitHub App.

Scroll down and select “Only Select Repository” to select a particular repository to deploy on Vercel.

Write your project name instead of “react-app-hosting” that you wanted to show in the URL.

Congratulations People You finally hosted your react application on vercel