Installing React JS and Setting up Your First Project on Localhost

Posted by


React JS is a popular front-end JavaScript library for building user interfaces. In this tutorial, we will walk you through the steps to install React JS and set up your first project in localhost.

Step 1: Install Node.js

Before you can start using React JS, you will need to have Node.js installed on your computer. Node.js is a JavaScript runtime that allows you to run JavaScript on the server-side. You can download Node.js from the official website and follow the installation instructions.

Step 2: Create a New React Project

To create a new React project, you can use the Create React App tool. Open your terminal and run the following command to install Create React App globally:

npm install -g create-react-app

Once Create React App is installed, you can create a new React project by running the following command:

create-react-app my-react-app

Replace my-react-app with the name of your project. This will create a new directory called my-react-app with all the necessary files and dependencies for a React project.

Step 3: Navigate to the Project Directory

After creating a new React project, navigate to the project directory by running the following command:

cd my-react-app

This will change the working directory to your React project directory.

Step 4: Start the Development Server

To start the development server and run your React project, run the following command:

npm start

This will launch the development server and open your React project in your default web browser. You should see a welcome message indicating that your React project is running successfully.

Step 5: Edit the React Component

Now that your React project is up and running, you can start editing the default React component. Open the src/App.js file in your text editor and make changes to the component.

For example, you can modify the App component to display a custom message:

import React from 'react';

function App() {
  return (
    <div>
      <h1>Welcome to My React App!</h1>
    </div>
  );
}

export default App;

Save the changes and your React project will automatically update in the browser to reflect the modifications.

Step 6: Stop the Development Server

When you are done working on your React project, you can stop the development server by pressing Ctrl + C in the terminal. This will stop the server and shut down your React project.

Congratulations! You have successfully installed React JS and set up your first project in localhost. You can continue building your React project by adding more components, styles, and functionality. React JS offers a rich ecosystem of libraries and tools to help you create interactive and dynamic user interfaces. Happy coding!

0 0 votes
Article Rating
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@shikharsingh1007
1 month ago

bro my react app is created but on browser my logo does not dynamically rotate why?