An out-of-the-box React frontend template
- PC: react-seed
- Mobile: react-template-mobile
- ๐ฑ Mobile version: react-template-mobile
- ๐ฆ Out of the box, no extra configuration required
- ๐ Key modules are well-commented for low learning cost
- ๐ Fast startup and compilation
- ๐ฑ Easy to customize and extend
- ๐ก๏ธ Strict code conventions
| Category | Stack | Version |
|---|---|---|
| Framework | React + ReactDOM | 19.x |
| Language | TypeScript | 5.x |
| Build | Vite + @vitejs/plugin-react |
8.x |
| Routing | react-router |
7.x |
| State | MobX + mobx-react-lite |
6.x / 4.x |
| Request | axios + axios-retry | 1.x |
| Style | Less + CSS Modules + PostCSS | โ |
| Icon | @phosphor-icons/react + local svg as React component (vite-plugin-svgr) |
โ |
| Convention | ESLint 9 (flat config) + Prettier + Stylelint + husky + lint-staged + commitlint | โ |
- Node โฅ 22.22.1 (CI pinned to 22.22.3 via volta)
- npm โฅ 7.0.0 / yarn โฅ 1.22.4 / pnpm โ pick one
# 1. Install dependencies (pick one)
npm install
# or
yarn install
# 2. Start dev server
npm run startnpm run build:qa # build for testing environment
npm run build:prod # build for production
npm run deploy # build and publish via gh-pages
npm run clean # clean node_modulesreact-seed/
โโโ vite.config.ts # Vite build config (alias / plugins / build / server)
โโโ index.html # HTML entry template (Vite root)
โโโ public/
โ โโโ favicon.ico # Static assets (copied as-is to build output)
โโโ src/
โ โโโ index.tsx # App mount entry
โ โโโ App.tsx # Root component + useRoutes
โ โโโ vite-env.d.ts # Vite types & import.meta.env declarations
โ โโโ router/ # Centralized routes (React.lazy + SuspenseLazy)
โ โโโ api/ # API layer (axios wrapper, grouped by page)
โ โโโ store/ # MobX stores
โ โโโ components/ # Common components (barrel exports)
โ โโโ view/ # Page-level components
โ โโโ constants/ # Constants / enums
โ โโโ interface/ # Business type definitions
โ โโโ types/ # Global .d.ts
โ โโโ utils/ # Utilities + custom hooks
โ โโโ assets/ # Static assets (incl. svg sprite)
โ โโโ styles/index.less # Global styles
โโโ docs/ # Design materials, UI references, English README
โโโ .env.development # Development env variables
โโโ .env.qa # QA env variables
โโโ .env.production # Production env variables
โโโ eslint.config.mjs # ESLint 9 flat config
โโโ tsconfig.json # TS config (with path alias)
โโโ AGENTS.md # Project guide for AI coding assistants
โโโ package.json
Defined in both tsconfig.json and vite.config.ts โ prefer alias over relative paths:
import {Button} from '@/components';
import {useStores} from '@/store';- Create
index.tsx+index.lessundersrc/view/XxxPage/ - Register a lazy-loaded route via
SuspenseLazyinsrc/router/index.tsx - Edit
src/view/Tab/index.tsxif a top-nav entry is needed
- Create
index.tsandtypes/<page-name>.tsundersrc/api/<page-name>/ - Import the wrapped
requestfrom../request, callrequest<ResponseT>({url, method, data}) - Keep request/response types co-located in the same
types/
- Call
makeAutoObservable(this)in store constructors; wrap async assignments withrunInAction(...) - Register new stores in
storesofsrc/store/index.ts - Components reading observables must be wrapped with
observer
For more conventions and AI collaboration notes, see AGENTS.md.
Commit messages follow commitlint:
git commit -m "<type>: <emoji> <subject>"
# example
git commit -m "feat: โจ Add order query page"Common types:
| type | emoji | description |
|---|---|---|
| feat | โจ | New feature |
| fix | ๐ | Bug fix |
| docs | ๐ | Documentation changes |
| style | ๐ | Style adjustments (no logic impact) |
| refactor | ๐จ | Refactor (no new feature, no bug fix) |
| perf | โก | Performance optimization |
| build | ๐ฆ | Build system or dependency changes |
| config | ๐ง | Configuration changes |
| chore | ๐ฅ | Miscellaneous |
| release | ๐ | Release a version |
| Branch | Description |
|---|---|
| main | Main branch |
| dev | Development branch |
| deploy | Demo deploy branch |
- Project tutorial: Building a React Project Development Template from 0 to 1
- Development reference: docs/data.md
- ๐ฌ Feel free to open Issues
- ๐งโโ๏ธ Pull Requests are welcome โ see how to contribute
- ๐ฑ If this project helps you, why not treat the developer's cat to a can of food โ cats are the real fuel that keeps this project running: Sponsor the project
The code and documentation of this project are released under the MIT License.
