Setting up a React project
Creating a React app with Vite, what Create React App's deprecation means for you, and the files a fresh project actually gives you.
Setting up a React project
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Vite is the current standard way to start a plain React project: it gives you a dev server with fast reloads and a build command, with almost no configuration.
- Create React App, once the default starting point, is deprecated and no longer the recommended way to start a new project — if you see it in an older tutorial, treat it as historical, not current advice.
- A full framework like Next.js or React Router is a different, equally valid starting point that adds routing and server rendering on top of React; this lesson covers the plain-React path, frameworks come later in this roadmap.
- A fresh Vite React project's entry point is main.jsx, which renders the top-level App component into a single div in index.html.
- npm run dev, npm run build, and npm run preview are the three scripts you'll use constantly: local development, producing an optimized build, and checking that build locally.
- index.html in a Vite project is not a static page to edit directly — it's a shell with one empty element that React takes over and fills.
Picking a starting point
There isn’t one official way to start a React project anymore — there are two reasonable ones, and knowing which to reach for matters as much as the mechanics of either. The first is a plain build tool that gives you React with (almost) nothing else: you write components, and you’re responsible for anything beyond that, like routing. The second is a framework — Next.js and React Router are the common choices — that bundles React with routing, data loading, and often server rendering, in exchange for more structure and more decisions made for you up front.
This lesson covers the first path, because it’s the right one for learning React’s own mechanics without a framework’s extra layer of conventions in the way. Frameworks, and when to reach for one instead, are covered later in this roadmap once you have the React fundamentals to evaluate what each one is adding.
Why not Create React App
If you search for “how to start a React project,” a lot of what comes back — tutorials, Stack Overflow answers, old blog posts — tells you to run npx create-react-app my-app. Don’t. Create React App (CRA) was the standard scaffolding tool for years, but it is now deprecated: its tooling fell behind, startup and rebuild times became noticeably slow as projects grew, and the React team no longer recommends it for new projects. It still runs, which is why it keeps showing up in older material, but treat any tutorial that leads with it as describing a tool that’s no longer the right default, not as current best practice.
Scaffolding with Vite
The current standard way to start a plain React project is Vite (pronounced “veet,” French for “fast”), a build tool that’s fast specifically because it serves your source files to the browser directly during development instead of bundling everything up front, and only bundles for production when you actually build.
npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev
The first command scaffolds a new folder (my-app) with React preconfigured. npm install pulls down the dependencies the template declares. npm run dev starts a local dev server — typically at http://localhost:5173 — that reloads your changes almost instantly as you save files.
What you actually get
A fresh template looks roughly like this:
my-app/
index.html
package.json
src/
main.jsx
App.jsx
index.css
index.html is a minimal shell, not a page you build out directly:
<!doctype html>
<html>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
That <div id="root"></div> is the single DOM node React takes over. Everything your app ever renders ends up inside it; the rest of the document stays untouched by React.
main.jsx is the entry point — the one place that connects your React code to that DOM node:
import { createRoot } from "react-dom/client";
import App from "./App.jsx";
createRoot(document.getElementById("root")).render(<App />);
createRoot tells React: “this DOM element is yours to manage.” .render(<App />) tells it what to put there — your top-level component. App.jsx is an ordinary component, the same shape you’ll write throughout this roadmap:
function App() {
return <h1>Hello, React</h1>;
}
export default App;
Everything your app does — every other component, every piece of state, every route if you add one — ultimately gets rendered somewhere inside this App tree.
The scripts you’ll actually run
package.json’s scripts section defines three commands you’ll use constantly:
npm run dev— starts the local dev server with fast reloads, for day-to-day development.npm run build— produces an optimized, bundled version of the app in adist/folder, ready to deploy.npm run preview— serves thatdist/build locally, so you can sanity-check what production will actually look like before deploying it.
Day to day, almost all of your time is spent in npm run dev; build and preview matter once you’re shipping something.
What the video covers
Traversy Media’s crash course is framed around Vite itself rather than React specifically, but it directly compares Vite to Create React App — the exact contrast this lesson opens with — before walking through scaffolding a project and its npm scripts. The React-template specifics (what main.jsx and App.jsx actually contain) get less screen time than the Vite tooling does, which is why this lesson’s own walkthrough above spells those files out directly; treat the video as the “why Vite, and the CLI mechanics” half, and the prose here as the “what’s inside the project it creates” half.
Where this fits
With a project scaffolded, the next step is understanding the <h1>Hello, React</h1> syntax inside App.jsx — that isn’t a string, and it isn’t quite HTML either. Next: JSX syntax and compilation.
Check yourself
What does running npm create vite@latest actually set up for you?
It scaffolds a new project folder with a minimal build and dev-server configuration (Vite), a package.json with the scripts you need, and a small set of starter files — an index.html shell, a main.jsx entry point, and a basic App.jsx component — ready to run with npm install and npm run dev.
Should a brand-new React project be started with Create React App in 2026?
No. Create React App is deprecated and is no longer the recommended way to start a React project; current guidance points to Vite for a plain React app, or to a framework like Next.js or React Router when you need routing and server rendering built in.
What is the actual relationship between index.html, main.jsx, and App.jsx in a Vite React project?
index.html is a minimal HTML shell containing one empty element (commonly a div with id="root") and a script tag loading main.jsx. main.jsx is the entry point: it finds that empty element and tells React to render the App component into it. App.jsx is the top-level component that defines what actually appears on the page.
When would you reach for a framework like Next.js instead of a plain Vite + React setup?
When the app needs things React alone doesn't provide out of the box, such as file-based routing, server-side rendering, or built-in data-loading conventions. That tradeoff is covered later in this roadmap; a plain Vite setup is the better starting point for learning React itself.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.