In this tutorial, you will learn how to quickly set up and run your very first React application using the Create React App tool. This official React setup tool provides a simple way to start a new React project with zero configuration.
React development requires Node.js and its package manager npm. To check if they are installed, open your terminal or command prompt and run:
node -v npm -v
If not installed, download Node.js from nodejs.org and install it. npm comes bundled with Node.js.
Use the npx
command to create a new React project named my-app
:
npx create-react-app my-app
This will create a new folder called my-app
with all necessary files and dependencies.
Navigate into your new appβs directory and start the development server with:
cd my-app npm start
This command will open your React app automatically in your default web browser at http://localhost:3000
. You will see a React welcome screen.
Key folders and files created:
public/
β Contains the static HTML file.src/
β Contains React components and main JavaScript files.package.json
β Holds project metadata and dependencies.
Open src/App.js
in a code editor and change the content inside the <div>
with something like:
return ( <div style={{ textAlign: 'center', marginTop: '50px' }}> <h1>Hello, React!</h1> <p>Welcome to your first React application.</p> </div> );
Save the file and see your changes instantly reflected in the browser thanks to Reactβs hot reloading feature.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!