Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Setting Up and Running a React Project with Vite | Running and Exploring a React Project
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Introduction to React

bookSetting Up and Running a React Project with Vite

So far, you've worked with isolated React examples. In real-world development, React applications are created and run as projects with a predefined structure and tooling.

In this chapter, you'll learn how to create and run a React project using Vite, a modern build tool that is fast, lightweight, and commonly used in production projects.

Creating a React Project with Vite

To create a new React project, open your terminal and run the following command:

npm create vite@latest

You will be prompted to:

  1. Enter a project name;
  2. Select a framework β†’ choose React;
  3. Select a variant β†’ choose JavaScript.

Once the setup is complete, navigate into the project folder:

cd project-name

Install the project dependencies:

npm install

Running the Development Server

To start the React development server, run:

npm run dev

After running this command:

  • Vite starts a local development server;
  • A local URL (usually http://localhost:5173) appears in the terminal;
  • Opening this URL in the browser displays your React app.

Any changes you make to the code will automatically update in the browser.

Understanding What Just Happened

When you ran the development server:

  • Vite bundled your React code;
  • React rendered the application into the browser;
  • The app entered development mode, optimized for fast feedback.

You now have a real React project running locally.

Note
Common Commands You'll Use

  • npm install: installs project dependencies;
  • npm run dev: starts the development server;
  • Ctrl/Cmd + C: stops the running server.

These commands are part of everyday React development.

question mark

What is Vite mainly used for?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 1

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

bookSetting Up and Running a React Project with Vite

Swipe to show menu

So far, you've worked with isolated React examples. In real-world development, React applications are created and run as projects with a predefined structure and tooling.

In this chapter, you'll learn how to create and run a React project using Vite, a modern build tool that is fast, lightweight, and commonly used in production projects.

Creating a React Project with Vite

To create a new React project, open your terminal and run the following command:

npm create vite@latest

You will be prompted to:

  1. Enter a project name;
  2. Select a framework β†’ choose React;
  3. Select a variant β†’ choose JavaScript.

Once the setup is complete, navigate into the project folder:

cd project-name

Install the project dependencies:

npm install

Running the Development Server

To start the React development server, run:

npm run dev

After running this command:

  • Vite starts a local development server;
  • A local URL (usually http://localhost:5173) appears in the terminal;
  • Opening this URL in the browser displays your React app.

Any changes you make to the code will automatically update in the browser.

Understanding What Just Happened

When you ran the development server:

  • Vite bundled your React code;
  • React rendered the application into the browser;
  • The app entered development mode, optimized for fast feedback.

You now have a real React project running locally.

Note
Common Commands You'll Use

  • npm install: installs project dependencies;
  • npm run dev: starts the development server;
  • Ctrl/Cmd + C: stops the running server.

These commands are part of everyday React development.

question mark

What is Vite mainly used for?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 1
some-alt