How to Create a React App with Vite

Scaffold a new React project with Vite in minutes. Follow the exact command, choose the React template, install dependencies, and start the development server.

5 min read

To create a React app with Vite, you run one command and answer a few prompts. Vite is a fast build tool that scaffolds the project, installs dependencies, and starts a development server on your machine. This guide uses JavaScript, and the same flow works for the TypeScript template.

If you are new to React, start with the guide on what React is. Then come back here to create your first project.

Create React App is deprecated

Create React App is no longer maintained and was sunset in early 2025. Use Vite for a client-only React project, or a framework such as Next.js when you need routing and server features.

Prerequisites

You need Node.js installed before you begin. Vite requires Node.js 20.19 or newer, or 22.12 or newer.

Check your version with this command:

bashbash
node --version

If the printed version is older, or the command is not found, install or upgrade Node.js before continuing.

Here is the whole setup at a glance, before the detail on each part:

Run the scaffold command

Run npm create vite@latest and give the project a name when prompted.

Choose the React template

Select React from the framework list, then pick a variant and a linter.

Install dependencies

Move into the new folder and run npm install.

Start the development server

Run npm run dev and open the printed localhost URL.

Scaffold the project

Run the scaffold command in the terminal, inside the folder where you keep your projects:

bashbash
npm create vite@latest

The tool asks for a project name, then shows a list of frameworks. Select React, and answer the prompts that follow:

  • Variant: choose JavaScript for this guide. TypeScript works the same way, and the React Compiler variants turn that compiler on for you.
  • Linter: Oxlint is the default, and ESLint is offered for the plain React templates.
  • Install and start now: answer no if you want to run the install and dev commands yourself, as the next section does.

You can also name the project and pick the variant up front, which skips the framework and variant prompts:

bashbash
npm create vite@latest my-app -- --template react

This creates a folder named my-app with the React JavaScript template.

Install and run

Move into the project folder and install the packages Vite listed in package.json:

bashbash
cd my-app
npm install

The install command reads package.json and downloads every dependency the template listed. It can take a minute on the first run.

Now start the development server:

bashbash
npm run dev

The terminal prints a local URL, usually http://localhost:5173. Open it in your browser and you should see the starter page with the Vite and React logos.

Edit your first component

Open the project in your editor and replace the contents of src/App.jsx with a simple component:

App.jsxApp.jsx
function App() {
  return <h1>Hello from React</h1>;
}
 
export default App;

Save the file. The browser updates almost instantly because Vite replaces only the changed module, a feature called hot module replacement. You do not need to refresh the page manually.

The guide on the React project structure explains every file this template created and where your future components should live.

Troubleshooting

  • If npm reports an unsupported Node version, upgrade Node to 20.19 or newer.
  • If the port is already in use, run npm run dev -- --port 5174 to pick another.
  • If the page is blank, check that src/main.jsx still calls createRoot on the element with id root.

What to learn next

Now that the app runs, build your first interactive component with the guide on your first React component. Then read the project structure guide to learn where each piece belongs and where your own files should live.

Rune AI

Rune AI

Key Insights

  • Use npm create vite@latest and select the React template.
  • Vite requires Node.js 20.19 or newer, or 22.12 or newer.
  • Install dependencies with npm install.
  • Start the dev server with npm run dev at localhost:5173.
  • Create React App is deprecated, so use Vite or a framework instead.
RunePowered by Rune AI

Frequently Asked Questions

What is the command to create a React app with Vite?

Run npm create vite@latest in your terminal, then select React when prompted. For a one-line setup with JavaScript, run npm create vite@latest my-app -- --template react.

What Node.js version does Vite require?

Vite requires Node.js 20.19 or newer, or 22.12 or newer. Some templates require a higher version, so upgrade if the package manager warns you.

What is the difference between Vite and Create React App?

Create React App is deprecated and no longer maintained. Vite is actively developed and is one of the build tools the React docs recommend for a project built from scratch, alongside Parcel and Rsbuild.

Conclusion

Vite is a quick, well supported way to start a client-only React project. Run npm create vite@latest, choose the React template, install dependencies, and start the dev server. You now have a project where you can edit components and see changes instantly.