React Project Setup with Vite

Harry · 22 Sep 2026 · 1 views
Log in to track your progress and mark lessons complete.

Prerequisites

Node.js 18+ with npm. Vite is the recommended tool (Create React App is deprecated).

Create a Project

npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev

Project Structure

src/ holds components, hooks and services; public/ holds static assets; index.html is the entry page.

Build and Env

npm run build   # outputs dist/
VITE_API_URL=https://api.example.com  # .env files

Only VITE_ prefixed variables are exposed to the browser.

Key Points

  • Vite gives instant dev server with HMR.
  • dist/ is deployed to any static host.
  • Never put secrets in client env vars.
Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in