Environment and Tooling
Project bootstrap
Vite is the standard build tool for client-side React applications, offering near-instant Hot Module Replacement (HMR) in development and Rollup-powered production bundles. Scaffold a new project with the React (or React + TypeScript) template and start the dev server:
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev
Scripts and pipeline
Every Vite-based React repository exposes three core lifecycle scripts in package.json:
devfor local iteration with fast HMR feedback.buildfor generating minified, hashed production assets intodist/.previewfor serving the compileddist/bundle locally to verify production behavior before deploying.
Linting and formatting
Configure ESLint (including eslint-plugin-react-hooks) alongside Prettier so hook dependency bugs are caught in the editor and formatting stays uniform across pull requests.
Environment variables
Vite exposes only variables prefixed with VITE_ (via import.meta.env.VITE_API_URL) to browser code. Remember that any variable bundled into a React client app is publicly visible to users—never place private API keys or database secrets in frontend environment files.
Professional tips
Keep local machines and CI runners aligned from day one:
- Pin your Node.js LTS version in
.nvmrcand CI workflow configs. - Commit
package-lock.json(orpnpm-lock.yaml) for deterministic installs. - Run lint, type-check, and
npm run buildon every pull request before merge.
Practice
Initialize a React app, add lint and build scripts, and create a CI pipeline that fails on lint or build errors.