ReactEasy
What is Vite?
Vite is a fast front-end build tool and dev server. In development it serves source files as native ES modules with near-instant hot module replacement; for production it bundles and optimizes the app. Vite 8 (March 2026) uses Rolldown as its single Rust-based bundler and Oxc for transforms, and it is the most common way to start a React SPA.
Why it is fast
- Dev: no upfront bundling. The browser requests modules and Vite transforms only what is requested. Dependencies are pre-bundled once.
- HMR: updates only the changed module, so React Fast Refresh keeps component state.
- Rust toolchain (Vite 8): Rolldown replaces the old esbuild-plus-Rollup split, and Oxc handles TypeScript/JSX transforms and minification.
Getting started with React
npm create vite@latest my-app -- --template react-ts- Templates:
react,react-ts,react-compiler,react-compiler-ts. @vitejs/plugin-reactv6 uses Oxc for Fast Refresh with no Babel dependency; the React Compiler is added throughreactCompilerPresetwith@rolldown/plugin-babel.
Features
- TypeScript, JSX, CSS Modules, PostCSS, Sass, Lightning CSS.
- Env variables via
import.meta.env(onlyVITE_-prefixed values are exposed to the client). - Plugin ecosystem compatible with Rollup plugins.
- SSR and library mode; frameworks such as React Router, TanStack Start, Astro and Remix-style setups build on Vite.
- Testing with Vitest, which reuses the Vite config.
Requirements
Node.js 20.19+ or 22.12+.
Vite vs a framework
Vite gives you a client-rendered SPA. For routing, data loading and SSR, add React Router or TanStack Router, or choose a framework.
Code example
tsx
1// Create a project2// npm create vite@latest my-app -- --template react-compiler-ts3// cd my-app && npm install && npm run dev45// vite.config.ts6import { defineConfig } from "vite";7import react from "@vitejs/plugin-react";89export default defineConfig({10 plugins: [react()],11 resolve: { alias: { "@": "/src" } },12 server: {13 port: 5173,14 proxy: { "/api": "http://localhost:8080" }, // avoid CORS in development15 },16});1718// src/config.ts - only VITE_ variables reach the browser19export const API_URL = import.meta.env.VITE_API_URL ?? "/api";
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the React set.