StealThis .dev

React + TypeScript + Vite Starter

Production-ready React starter with Vite, TypeScript, ESM dev server, and Rollup production builds. Includes path aliases and optimal defaults.

在 Lab 中打开
react vite typescript
目标: HTML

代码

React + TypeScript + Vite Starter

The fastest way to scaffold a modern React project with full TypeScript support. One command gives you a production-ready setup with Vite’s blazing-fast ESM dev server and optimized Rollup builds.

Quick Start

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

This scaffolds a complete React 18+ project with TypeScript, JSX transform, HMR, and a pre-configured build pipeline.

What You Get

  • Vite dev server — Native ESM, sub-50ms HMR, no bundling during development
  • TypeScript — Strict mode enabled, path aliases ready via tsconfig.json
  • React 18+ — Concurrent features, automatic JSX runtime
  • Rollup production builds — Tree-shaking, code splitting, optimized chunks
  • ESLint — Pre-configured with React and TypeScript rules
  • CSS Modules — Supported out of the box, no extra config needed

Generated Project Structure

my-app/
├── public/
│   └── vite.svg
├── src/
│   ├── assets/
│   │   └── react.svg
│   ├── App.css
│   ├── App.tsx
│   ├── index.css
│   ├── main.tsx
│   └── vite-env.d.ts
├── index.html
├── package.json
├── tsconfig.json
├── tsconfig.app.json
├── tsconfig.node.json
└── vite.config.ts

Key Files

  • vite.config.ts — Plugins, aliases, build options. Add @vitejs/plugin-react-swc for faster refresh.
  • tsconfig.json — Project references setup. tsconfig.app.json handles app code, tsconfig.node.json handles config files.
  • main.tsx — App entry point. Renders into #root using createRoot.
  • index.html — Vite uses this as the entry; the <script type="module"> tag points to main.tsx.

Extend With

ToolPurpose
React RouterClient-side routing with loaders and actions
TanStack QueryServer state management, caching, and synchronization
VitestVite-native unit testing with Jest-compatible API
Tailwind CSSUtility-first CSS framework
ZustandLightweight state management

References