使用 Vite 作为开发服务器与构建工具,配合 React 与 TypeScript
React-Vite-Tanstack-Starter-Template — Vite 启动器模板
作者 whereissam
基于 Vite 与 React 的启动器模板,集成 TanStack Router/Query、TailwindCSS v4 与 shadcn/ui(Base UI 基础组件),并内置测试、代码质量与 AI 协作配置。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
集成 TanStack Router 文件式路由与 TanStack Query 数据请求
采用 TailwindCSS v4 与 shadcn/ui(Base UI 基础组件),默认提供 button、card、input
内置 Vitest 与 Testing Library 单元测试环境
配置 ESLint、Prettier、lefthook 提交前钩子、GitHub Actions CI 与 Dependabot
包含 AGENTS.md、llms.txt、.mcp.json 等面向 AI 编码工具的配置文件
模板详细介绍
这是一个面向 React 项目的启动器模板,使用 Vite 作为构建工具,React 作为 UI 框架,并采用 TypeScript 提供类型安全。路由由 TanStack Router 以文件式方式管理,数据请求与缓存由 TanStack Query 承担。样式层使用 TailwindCSS v4,并通过 Vite 插件接入;组件来自 shadcn/ui,构建在 Base UI 基础组件之上,模板默认包含 button、card 和 input。
模板还预置了 Vitest 与 Testing Library 的单元测试环境、ESLint 与 Prettier 的代码检查与格式化、lefthook 与 lint-staged 的提交前钩子,以及 GitHub Actions CI 和 Dependabot 依赖更新。仓库中包含 AGENTS.md、CLAUDE.md、llms.txt、.cursor/rules 和 .mcp.json 等文件,用于配合 AI 编码工具。
使用前需要留意:模板要求 Bun 1.0+,或 Node.js 20.19+/22.12+ 作为工具链环境;shadcn/ui 组件基于 Base UI,与 Radix 版本在 API 上存在差异(例如用 render 属性替代 asChild)。演示站点与截图仅用于展示,第三方素材的许可需单独核对。
适合你的项目吗?
适用场景
- 需要快速搭建 React + Vite + TypeScript 项目骨架时
- 希望使用 TanStack Router 文件式路由与 TanStack Query 管理路由和数据请求时
- 计划采用 TailwindCSS v4 与 shadcn/ui(Base UI)构建界面时
- 需要在项目初期就具备单元测试、代码检查、格式化与 CI 流程时
- 希望配合 AI 编码工具进行开发并需要相应约定文件时
适合人群
- 熟悉 React、TypeScript 与 Vite 的前端开发者
- 需要类型安全路由与数据请求方案的项目
- 希望使用 shadcn/ui 与 TailwindCSS v4 的界面开发场景
- 重视代码质量工具链与自动化流程的团队或个人
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
需要 Bun 1.0+,或 Node.js 20.19+/22.12+ 作为工具链环境
- 2
可通过 GitHub 的 Use this template 按钮创建新仓库,或直接克隆仓库
- 3
安装依赖使用 bun install,启动开发服务器使用 bun run dev,默认地址为 http://localhost:5173
- 4
添加 shadcn/ui 组件时需传入 --base base 以安装 Base UI 版本
- 5
从 Radix 迁移时注意 Base UI 用 render 属性替代 asChild
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用该模板需要先安装 Bun 1.0+,或使用 Node.js 20.19+/22.12+ 作为工具链环境,否则无法运行安装与开发命令。
- 通过 shadcn CLI 添加组件时必须传入 --base base 参数,否则会安装 Radix 版本而非模板所基于的 Base UI 版本。
- 组件基于 Base UI,与 Radix 的 API 不同:需用 render 属性替代 asChild 来更换底层元素,从 Radix 迁移时需改写相关代码。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
**Prerequisites:** [Bun](https://bun.sh) 1.0+ (Node.js 20.19+ / 22.12+ also works for the toolchain).
README 原文
pass `--base base` so it installs the Base UI versions
README 原文
https://github.com/whereissam/React-Vite-Tanstack-Starter-Template/blob/main/LICENSEhttps://github.com/whereissam/React-Vite-Tanstack-Starter-Template/blob/main/README.mdBase UI replaces the `asChild` prop with a `render` prop.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-02。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 88 / 100
- 技术栈
- Vite · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-10-02
- 截图检查日期
- 2026-10-02
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Vite。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 3642af0e11ce82676ab826ae005efaa1c93c595a9a81cb605ebf95ce37110c0c
2026-10-02T11:36:23.950Z
来源文件 / 仓库<div align="center">
# React · Vite · TanStack Starter
A modern, type-safe React starter template — **Vite**, **TanStack Router & Query**, **TailwindCSS v4**, and **shadcn/ui** on **Base UI** primitives.
[](https://github.com/whereissam/React-Vite-Tanstack-Starter-Template/actions/workflows/ci.yml)
[](#license)




</div>
---
## Features
- **Vite 8** — lightning-fast dev server and build
- **React 19** — the latest React with modern features
- **TypeScript** — strict, end-to-end type safety
- **TailwindCSS v4** — utility-first styling via the new Vite plugin
- **shadcn/ui** — beautiful, accessible components on **Base UI** primitives
- **TanStack Router** — type-safe, file-based routing
- **TanStack Query** — data fetching, caching, and server state
- **Vitest** — unit testing with Testing Library
- **ESLint + Prettier** — linting and formatting (Tailwind class sorting) out of the box
- **AI-agent ready** — `AGENTS.md`, `llms.txt`, and `.mcp.json` so AI tools work productively in this repo
- **Pre-commit hooks** — lefthook + lint-staged auto-fix staged files
- **CI + Dependabot** — GitHub Actions (lint, typecheck, format, test, build) and weekly dependency updates
## Quick Start
> Click **["Use this template"](https://github.com/whereissam/React-Vite-Tanstack-Starter-Template/generate)** on GitHub to start a new repo from this starter.
```bash
# 1. Clone (or use the template button above)
git clone https://github.com/whereissam/React-Vite-Tanstack-Starter-Template.git
cd React-Vite-Tanstack-Starter-Template
# 2. Install dependencies
bun install
# 3. Start the dev server
bun run dev
```
Then open **[http://localhost:5173](http://localhost:5173)**.
> **Prerequisites:** [Bun](https://bun.sh) 1.0+ (Node.js 20.19+ / 22.12+ also works for the toolchain).
## Scripts
| Command | Description |
| ---------------------- | --------------------------------------------------- |
| `bun run dev` | Start the development server |
| `bun run build` | Type-check and build for production |
| `bun run preview` | Preview the production build |
| `bun run lint` | Run ESLint |
| `bun run typecheck` | Type-check only (`tsc --noEmit`) |
| `bun run format` | Format all files with Prettier |
| `bun run format:check` | Check formatting without writing |
| `bun run check` | Lint + typecheck + format check |
| `bun run verify` | Full gate: check + test + build (run before "done") |
| `bun run test` | Run the test suite once |
| `bun run test:watch` | Run tests in watch mode |
## Components
This template ships with `button`, `card`, and `input` from **shadcn/ui**, built on **Base UI** primitives. Add more with the CLI — pass `--base base` so it installs the Base UI versions:
```bash
bunx shadcn@latest add dialog --base base
bunx shadcn@latest add dropdown-menu --base base
```
> **Migrating from Radix?** Base UI replaces the `asChild` prop with a `render` prop.
> To change a component's underlying element, pass an element to `render`:
>
> ```tsx
> // Radix: <Button asChild><a href="/">Home</a></Button>
> // Base UI: <Button render={<a href="/" />}>Home</Button>
> ```
## Project Structure
```
src/
├── components/
│ ├── ui/ # shadcn/ui components (Base UI primitives)
│ └── ... # app-level components (nav, theme, etc.)
├── lib/
│ └── utils.ts # cn() and other helpers
├── routes/ # TanStack Router file-based routes
│ ├── __root.tsx # Root layout route
│ └── index.tsx # Home route (/)
├── test/
│ └── setup.ts # Vitest + Testing Library setup
├── main.tsx # App entry
└── index.css # Tailwind + design tokens
```
## Tech Stack
| Layer | Tools |
| -------------- | ------------------------------------------------------------ |
| **Framework** | React 19, TypeScript |
| **Build** | Vite 8 |
| **Routing** | TanStack Router (file-based) |
| **Data** | TanStack Query |
| **Styling** | TailwindCSS v4, `class-variance-authority`, `tailwind-merge` |
| **Components** | shadcn/ui on Base UI, Lucide icons |
| **Testing** | Vitest, Testing Library |
| **Quality** | ESLint, Prettier, lefthook, GitHub Actions CI, Dependabot |
## Routing
Routing is file-based via TanStack Router — add a file in `src/routes/` and the route tree is generated automatically:
| File | Route |
| --------------------------- | ------------- |
| `src/routes/index.tsx` | `/` |
| `src/routes/about.tsx` | `/about` |
| `src/routes/blog/index.tsx` | `/blog` |
| `src/routes/blog/$slug.tsx` | `/blog/:slug` |
## Styling
TailwindCSS v4 is wired through the Vite plugin and a semantic design-token system (see [`docs/design-system.md`](./docs/design-system.md)). It supports:
- CSS-variable design tokens with light/dark mode
- Component variants with `class-variance-authority`
- Class merging with `tailwind-merge`
## Testing
Unit tests run on **Vitest** with **Testing Library** in a jsdom environment. Tests live next to the code they cover (e.g. `src/components/ui/button.test.tsx`):
```bash
bun run test # run once
bun run test:watch # watch mode
```
## AI-Agent Ready
This template is built to be productive with AI coding tools out of the box:
| File | Purpose |
| ---------------- | ----------------------------------------------------------------- |
| `AGENTS.md` | Canonical conventions read by Cursor, Copilot, Codex, and others |
| `CLAUDE.md` | Pointer to `AGENTS.md` for Claude Code |
| `llms.txt` | Concise project map in the [llms.txt](https://llmstxt.org) format |
| `.cursor/rules/` | Cursor rule that defers to `AGENTS.md` |
| `.mcp.json` | MCP servers (ships with Playwright for UI verification) |
Guardrails keep AI-generated changes honest: ESLint + Prettier, a **lefthook**
pre-commit hook that auto-fixes staged files, a `bun run verify` gate (lint +
typecheck + format + test + build), and **Dependabot** for weekly dependency
updates.
## License
Released under the **MIT License** — free to use for personal and commercial projects.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

react-starter-kit
Modern React starter kit with Bun, TypeScript, Tailwind CSS, tRPC, Stripe, and Cloudflare Workers. Production-…
Vite · SaaS

cove
The Cove Stack: 🏝️ minimal TanStack Start template with Vite+, Better Auth, Drizzle ORM, shadcn/ui
Vite · SaaS

vite-react-boilerplate
A production ready, scalable starter template for Vite + React
Vite · 启动器

react-vite-admin
This Starter utilizes React, Recoil, React Query, React Hooks, Typescript, Axios And Vite. 全新技术栈的后台管理系统
Vite · 后台

typescript-react_best_practices-vite_template
<⚡⚛️> Start your React project with Vite following code best practices (TypeScript, Linting, testing, CI/CD…)
Vite · 启动器

cloudflare-starter-kit
Template (boilerplate) repository for scaffolding Cloudflare Workers projects
Vite · 启动器
