Environment and Tooling

Professional React work depends on stable tooling, repeatable scripts, and reliable local-to-CI parity.

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:

  • dev for local iteration with fast HMR feedback.
  • build for generating minified, hashed production assets into dist/.
  • preview for serving the compiled dist/ 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:

  1. Pin your Node.js LTS version in .nvmrc and CI workflow configs.
  2. Commit package-lock.json (or pnpm-lock.yaml) for deterministic installs.
  3. Run lint, type-check, and npm run build on 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.