TExcelTAD
Home › React › React Get Started

React Get Started

To build a real React project on your own computer you need Node.js and a build tool. The recommended way to start a plain React app today is Vite: it starts instantly, reloads your page as you save, and produces an optimized build for production.

Note: You don't need any of this to follow the course — every example on ExcelTAD runs in your browser. Set up a local project when you want to build something of your own.

Step 1: Check Node.js

Install the LTS version of Node.js from nodejs.org, then check it in a terminal:

bash · try it yourself
node --version
npm --version
v22.11.0
10.9.0

Any Node version 20.19+ or 22.12+ works with current Vite.

Step 2: Create the project

npm create vite@latest downloads the project generator and asks a few questions. You can answer them up front with flags:

bash · try it yourself
npm create vite@latest my-react-app -- --template react
> npx
> create-vite my-react-app --template react

│
◇  Scaffolding project in /home/you/my-react-app...
│
└  Done. Now run:

  cd my-react-app
  npm install
  npm run dev

Use --template react-ts instead if you want TypeScript from the start.

Step 3: Install and run

bash · try it yourself
cd my-react-app
npm install
npm run dev
added 152 packages, and audited 153 packages in 9s

> my-react-app@0.0.0 dev
> vite

  VITE v7.1.3  ready in 312 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

Open http://localhost:5173/ in your browser. Leave the dev server running: every time you save a file, the page updates in place (this is called Hot Module Replacement).

What's inside the project?

File / folder Purpose
index.html The single HTML page; contains <div id="root"></div>
src/main.jsx Entry point: mounts the App component into #root
src/App.jsx Your first component — start editing here
src/*.css Stylesheets imported by components
public/ Static files copied as-is (favicons, images)
package.json Dependencies (react, react-dom) and scripts
vite.config.js Vite configuration with the React plugin

The entry point

src/main.jsx is short. It finds the root element and tells React to render your App component inside it:

jsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App.jsx';

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>
);

StrictMode is a development helper: it runs some code twice on purpose to reveal bugs. It has no effect in production builds.

Try it here: a minimal App.jsx

Replace the generated App.jsx with something tiny. This is exactly what you would see in the browser:

jsx · try it yourself
import { useState } from 'react';

export default function App() {
  const [name, setName] = useState('world');

  return (
    <main style={{ fontFamily: 'system-ui', padding: 16 }}>
      <h1>Hello, {name}!</h1>
      <input value={name} onChange={(e) => setName(e.target.value)} />
      <p>Edit <code>src/App.jsx</code> and save to reload.</p>
    </main>
  );
}

The scripts in package.json

bash · try it yourself
npm run build
npm run preview
> my-react-app@0.0.0 build
> vite build

vite v7.1.3 building for production...
✓ 32 modules transformed.
dist/index.html                   0.46 kB │ gzip:  0.30 kB
dist/assets/index-D8b4DHJx.css    1.39 kB │ gzip:  0.71 kB
dist/assets/index-C3x9pO2a.js   188.05 kB │ gzip: 59.15 kB
✓ built in 1.02s

> my-react-app@0.0.0 preview
> vite preview

  ➜  Local:   http://localhost:4173/
Script What it does
npm run dev Development server with instant reloads
npm run build Optimized production files in dist/
npm run preview Serves the dist/ build locally to test it
npm run lint Runs ESLint with React rules

Tip: Install the React Developer Tools browser extension. It adds Components and Profiler tabs to DevTools so you can inspect props and state of every component.

Other ways to start

  • A framework such as Next.js or React Router (framework mode) when you need routing, server rendering and data loading built in.
  • A script tag for quick experiments — not recommended for real apps, because JSX must be compiled.

Test yourself

Which command scaffolds a new React project with Vite?

  1. npm install react-app
  2. npm create vite@latest my-app -- --template react
  3. npx react new my-app
  4. vite init react

Which file mounts the App component into the page in a Vite React project?

  1. index.html
  2. vite.config.js
  3. src/main.jsx
  4. package.json

What does npm run build produce?

  1. A development server
  2. Optimized static files in dist/
  3. A new React component
  4. A test report