Getting started with React takes under two minutes when you use Vite as your build tool. Vite compiles JSX quickly, serves instant hot module reloads, and replaces the legacy create-react-app CLI. Before running setup commands, install Node.js 20 LTS or newer on your machine.
Open your terminal in your projects folder and run the Vite scaffold command. Notice how the --template react flag generates a clean JavaScript starter without extra bloat.
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev
After npm run dev finishes, open http://localhost:5173 in your browser. Every time you save a file in src/, Vite updates the page without losing local component state.
| File or Folder | Responsibility |
|---|---|
index.html |
Hosts the single <div id="root"></div> mount point |
src/main.jsx |
Mounts the React tree with createRoot |
src/App.jsx |
Defines your top-level application component |
package.json |
Lists react, react-dom, scripts, and Vite plugins |
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.jsx';
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>
);
npm install.npm run dev before running cd my-react-app fails because no package.json exists in the parent directory.create-react-app is deprecated and installs outdated webpack dependencies. Use Vite for single-page apps or Next.js for full-stack apps.No. Keep react and react-dom inside each project's package.json so different projects can safely use different React versions.
Yes. You can experiment with React in browser sandboxes or load ESM builds in an HTML page, though real projects always use a local bundler like Vite.
Create a src/components/ directory and store each component in its own PascalCase file such as src/components/UserCard.jsx.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With