![]() |
The create react app command allows us to create a development environment and install all necessary libraries for creating single-page applications using React. The CRA tool is used to set up a new React project quickly, providing a standard structure and configuration. It includes a development server, build scripts, and support for modern JavaScript features and CSS preprocessors. It allows us to use the latest JavaScript features. Let’s see a step-by-step guide to create a new react application. Prerequisites:To create a new React app, you need to have the following installed on your system:
React Environment Setup
Steps to Create React AppStep 1: Initialize the React App Using create-react-appIf you have installed an npm version greater than or equal to 5.6, you can use the following npx command to create a new React app: npx create-react-app app_name If you are using npm version 5.1 or less than this, you cannot use the npx command, you need to install the create-react-app globally. Then, you can use the following command to create a new React app: npm install -g create-react-app The create-react-app command will create a frontend. It will not create any backends or databases. After running the above command the following React app directory structure will be created: Step 2: Switch to the project directoryOnce the project is created switch to the project directory using the following command: cd app_name Step 3: Start the developement serverTo run the app, use the following command. This command will locally run your app. npm start React Project Structure
![]() npx create-react-app my_app Dependencies in the package.json file: "dependencies": { Example: Below is an example of React App to display Hello gfg:
Start your application using the following command: npm start Output: ![]() |
Reffered: https://www.geeksforgeeks.org
ReactJS |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |