An opinionated starter template for React projects with TypeScript, Vite, and Sass.
- React with
react-router-dom(lazy loading, error boundary) - TypeScript with strict mode
- Sass (SCSS) with a minimal reset and CSS custom properties (light/dark via
prefers-color-scheme) - ESLint flat config with
typescript-eslint,react-hooks, andreact-refreshplugins - pnpm as the enforced package manager
src/
├── components/
│ └── ErrorBoundary.tsx
├── pages/
│ ├── Home
│ ├── About
│ └── NotFound
├── index.scss
└── main.tsx
pnpm install
pnpm dev| Command | Description |
|---|---|
pnpm dev |
Start dev server |
pnpm build |
Lint, type-check, and build |
pnpm preview |
Preview production build locally |
pnpm lint |
Run ESLint |
pnpm lint:fix |
Run ESLint with auto-fix |
- Styles: Edit
src/index.scssto change the color palette, fonts, or add variables. Add individual component-level.scssfiles as you expand the site. - Routing: Add new pages in
src/pages/and register routes inmain.tsx. Uselazy()+<Suspense>for code-split routes. - Context providers: Wrap
<RouterProvider />inmain.tsxwith any context providers you need (e.g. theme, auth).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Oxc
- @vitejs/plugin-react-swc uses SWC
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])