A new Vite React project contains a handful of files, and each has one clear job: index.html is the page the browser loads, src/main.jsx mounts React into it, src/App.jsx is your first component, and package.json and vite.config.js describe dependencies and build settings. Knowing what each file does tells you where to put your own code and what you can safely leave alone.
This guide walks through the React project folder structure created by npm create vite@latest with the React template. File names can vary a little between template versions, and TypeScript projects use .tsx instead of .jsx.
After you create and install a project, you will see something like this:
You will spend almost all your time inside src. The other files configure tools and rarely change.
Unlike Create React App, Vite keeps index.html in the project root, not in public. It is the one HTML page of your single-page app.
The empty <div id="root"> is where React draws your interface. The <script type="module"> loads your entry file. Change the <title> and add meta tags here.
This file connects React to the page.
createRoot takes the root element and render shows your App inside it. StrictMode is a development helper that runs extra checks, such as rendering components twice, to reveal bugs. It does nothing in production. Imports of CSS files are handled by Vite.
App.jsx is the top-level component. The starter contains a counter, which you will usually delete and replace.
As the app grows, add new components in their own files, for example src/components/Header.jsx, and import them into App. Files that contain JSX should use the .jsx extension (or .tsx), since Vite expects it.
src/index.css: global styles that apply to the whole app, imported in main.jsx.src/App.css: styles for the App component, imported in App.jsx. CSS imports are global, so class names can collide across files.src/assets/: images and fonts you import in code, for example import logo from "./assets/react.svg". Vite hashes their names in the build for caching.public/: files copied as they are and served from the root, such as favicon.ico or robots.txt. Reference them with an absolute path like /vite.svg.Use src/assets when a file is imported by a component, and public for files that need a fixed URL.
package.json lists dependencies and scripts:
npm run dev starts the development server.npm run build writes optimised files to a dist folder for deployment.npm run preview serves the built dist folder locally to check it.vite.config.js holds build settings and plugins. The React template adds the React plugin:
You add options here later, such as a development proxy or path aliases. package-lock.json records the exact versions installed, so commit it.
| File or folder | Purpose | Edit it? |
|---|---|---|
eslint.config.js | Lint rules that catch common mistakes | Sometimes |
.gitignore | Tells Git to skip node_modules and dist | Rarely |
README.md | Project notes | Yes |
node_modules/ | Installed packages | Never |
dist/ | Build output, created by npm run build | Never |
Create a folder such as src/components and put one component per file there, then import them into App.jsx. Vite does not require this structure, so organise it to suit your project.
In Vite, index.html is the entry of the build and Vite processes its script and link tags. Files in public are copied unchanged.
Yes. The starter code is only an example. Keep main.jsx, index.html and one root component, and remove the rest.
It is the production build created by npm run build. Upload its contents to a static host. It is generated, so do not edit it or commit it.
In a Vite React project, index.html provides the root element, main.jsx mounts React, and App.jsx is your first component. Styles and imported images live in src, fixed-URL files in public, and tooling settings in package.json, vite.config.js and eslint.config.js. Work inside src, leave node_modules and dist alone, and commit the lock file.