ViteReact启动器

vite-react-tailwind-starter — Vite 启动器模板

作者 agustinusnathaniel

基于 Vite、React、TypeScript 与 Tailwind CSS 的启动模板,集成 TanStack Router 文件路由、TanStack Query、Zod 环境变量校验、Biome、Vitest 与 Git 钩子。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-02查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

文件式路由:在 src/routes/ 中定义路由,TanStack Router 自动生成路由树

02

Tailwind CSS 集成,支持深色/浅色/跟随系统主题切换

03

使用 Zod 在构建时校验环境变量,并在代码中提供类型安全访问

04

内置 Biome 代码检查与格式化、Vitest 测试、TypeScript 类型检查

05

配置 Husky 与 Commitlint,在提交与推送阶段执行代码质量检查

06

提供 Vercel、Netlify、Cloudflare Workers 的部署配置说明

模板详细介绍

这是一个用于初始化 React 应用的启动模板,仓库描述为“template to initialize TanStack router app with TailwindCSS setup”。技术组合包括 Vite、React、TypeScript、Tailwind CSS、TanStack Router 与 TanStack Query,并配有 Biome、Vitest、Husky、Commitlint 等开发工具。

模板提供文件式路由(src/routes/ 下定义路由,自动生成路由树)、按路由组织的页面组件(src/lib/pages/)、应用外壳布局(src/lib/layout/)、可复用组件(src/lib/components/,含主题切换与主题提供者)、全局样式(src/lib/styles/globals.css)以及工具函数与示例测试。环境变量通过 env.ts 中的 Zod schema 在构建时校验,代码中通过 import.meta.env 访问。

开发流程方面,README 列出 pnpm dev、pnpm build、pnpm test、pnpm biome:check、pnpm type:check 等命令,并说明 Git 钩子会在提交前运行格式化与 lint、校验提交信息格式、推送前运行完整检查。部署配置覆盖 Vercel、Netlify 与 Cloudflare Workers,构建输出目录为 dist/client。

模板不包含后端 API、认证授权逻辑、数据库集成、TanStack Query 之外的状态管理库,也不提供基础布局组件之外的 UI 组件库。使用前需注意 README 中声明的 Node.js 与 pnpm 版本要求。

ViteReact启动器

适合你的项目吗?

适用场景

  • 需要快速搭建带文件路由与 Tailwind CSS 的 React 单页应用
  • 希望在新项目中直接使用 TypeScript 严格模式与类型安全的环境变量
  • 需要 TanStack Query 管理服务端状态并配合 TanStack Router 组织页面
  • 希望用 Biome 替代 ESLint/Prettier,并配合 Git 钩子约束提交规范
  • 需要为 Vercel、Netlify 或 Cloudflare Workers 准备可部署的构建配置

适合人群

  • 熟悉 React、TypeScript 与 Vite 的前端开发者
  • 需要文件式路由与 Tailwind CSS 起步配置的项目
  • 希望统一代码检查、格式化与测试流程的团队
  • 准备部署到 Vercel、Netlify 或 Cloudflare Workers 的静态前端项目

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    README 声明需要 Node.js ^24.11.x 与 pnpm 10.24.0

  2. 2

    可通过 GitHub 的 Use this template 或 npx degit 获取代码,然后执行 pnpm install

  3. 3

    开发服务器默认运行在 http://localhost:3000,生产构建输出到 dist/client

  4. 4

    环境变量需以 VITE_ 前缀定义,并在 env.ts 中补充 Zod schema

  5. 5

    新增路由在 src/routes/ 下创建文件并导出 createFileRoute 生成的 Route

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 使用该模板需要 Node.js 版本为 ^24.11.x,低于或高于此范围的 Node.js 环境可能无法正常运行。
  • 项目指定使用 pnpm 10.24.0 作为包管理器,使用 npm 或 yarn 等其他包管理器可能无法保证依赖安装与脚本执行一致。
  • 部署时构建命令须为 pnpm build,产物输出目录为 dist/client,配置错误会导致部署失败。
  • 环境变量需在 env.ts 中以 Zod schema 定义并在构建时校验,未按此方式声明的变量无法获得类型安全访问。
  • 自定义环境变量必须以 VITE_ 前缀命名并写入 .env 文件,否则无法通过 import.meta.env 访问。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

**Node.js**: ^24.11.x (specified in `engines`)

README 原文

**pnpm**: 10.24.0 (specified in `packageManager`)

README 原文

- **Build command**: `pnpm build` - **Output directory**: `dist/client`

README 原文

Environment variables are validated at build time using Zod. Define your schema in `env.ts`:

README 原文

2. Create `.env` file with your variables (prefixed with `VITE_`)

README 原文
https://github.com/agustinusnathaniel/vite-react-tailwind-starter/blob/main/LICENSEhttps://github.com/agustinusnathaniel/vite-react-tailwind-starter/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-02。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 92 / 100
技术栈
Vite · React
网站类型
启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-09-28
截图检查日期
2026-10-02

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Vite。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。

查看当时使用的来源资料

SHA-256: bb149437e395e1de667c57670ff165b8a731bc9b0c9c64b61e933b33b4ce93d3

2026-10-02T18:14:02.883Z

来源文件 / 仓库
# Vite React Tailwind Starter

<img src="https://og.sznm.dev/api/generate?heading=vite-react-tailwind-starter&text=React+vite+template+with+TailwindCSS+and+TypeScript+setup.&template=color&center=true&height=330" />

A production-ready starter template for React applications built with Vite, TypeScript, and Tailwind CSS v4. This template provides a modern development experience with file-based routing, type-safe environment variables, and comprehensive tooling for code quality and testing.

[**Live Demo**](https://vite-react-tailwind-starter.sznm.dev/)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/git?s=https://github.com/agustinusnathaniel/vite-react-tailwind-starter) [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/agustinusnathaniel/vite-react-tailwind-starter)

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/agustinusnathaniel/vite-react-tailwind-starter)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=bugs)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter) [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=sozonome_vite-react-tailwind-starter&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=sozonome_vite-react-tailwind-starter)

## Overview

This template solves the problem of bootstrapping a modern React application with:
- **Fast development**: Vite-based HMR and build pipeline
- **Type safety**: Full TypeScript coverage with strict mode
- **Routing**: File-based routing via TanStack Router
- **Styling**: Tailwind CSS v4 with dark mode support
- **State management**: TanStack Query for server state
- **Code quality**: Biome for linting/formatting, TypeScript checking, and testing
- **Developer experience**: DevTools integration, environment validation, and PWA support

### What This Template Provides

- Production-ready build configuration
- Type-safe environment variable validation
- File-based routing with code splitting
- Theme system with dark/light/system modes
- Testing setup with Vitest
- Git hooks for code quality enforcement
- Deployment configurations for Vercel, Netlify, and Cloudflare Workers

### What This Template Does Not Provide

- Backend API implementation
- Authentication/authorization logic
- Database integration
- State management library (beyond TanStack Query)
- UI component library (beyond basic layout components)

## Architecture

```mermaid
graph TB
    subgraph "Build Time"
        A[Vite Config] --> B[TypeScript Compiler]
        A --> C[Tailwind CSS v4]
        A --> D[TanStack Router Plugin]
        A --> E[React Compiler]
        D --> F[Route Tree Generation]
    end
    
    subgraph "Runtime"
        G[main.tsx] --> H[QueryClientProvider]
        H --> I[RouterProvider]
        I --> J[__root.tsx]
        J --> K[Layout Component]
        K --> L[ThemeProvider]
        K --> M[Header/Footer]
        J --> N[Route Components]
        N --> O[Page Components]
    end
    
    subgraph "Development"
        P[Vite Dev Server] --> Q[HMR]
        R[Biome] --> S[Linting/Formatting]
        T[Vitest] --> U[Test Runner]
        V[Husky Hooks] --> W[Pre-commit Checks]
    end
    
    F --> I
    B --> G
    C --> G
```

### Core Modules

| Module | Location | Responsibility |
|--------|----------|----------------|
| **Routing** | `src/routes/` | File-based route definitions, auto-generated route tree |
| **Pages** | `src/lib/pages/` | Page-level components organized by route |
| **Layout** | `src/lib/layout/` | Application shell (Header, Footer, Layout wrapper) |
| **Components** | `src/lib/components/` | Reusable UI components (ThemeProvider, ThemeToggle) |
| **Services** | `src/lib/services/` | Shared services and constants (QueryClient) |
| **Utils** | `src/lib/utils/` | Pure utility functions |
| **Styles** | `src/lib/styles/` | Global CSS and Tailwind configuration |

## Tech Stack

### Core Dependencies

- **React 19.2.0**: UI library
- **Vite 7.1.20** (rolldown-vite): Build tool and dev server
- **TypeScript 5.9.3**: Type system
- **Tailwind CSS 4.1.17**: Utility-first CSS framework
- **TanStack Router 1.135.2**: Type-safe file-based routing
- **TanStack Query 5.90.7**: Server state management
- **Zod 4.1.12**: Runtime type validation

### Development Tools

- **Biome 2.3.4**: Linter and formatter (replaces ESLint/Prettier)
- **Vitest 4.0.8**: Test runner
- **Husky 9.1.7**: Git hooks
- **Commitlint**: Conventional commit validation
- **Turbo**: Task runner for parallel execution

### Build Plugins

- `@vitejs/plugin-react`: React support with Fast Refresh
- `@tanstack/router-plugin`: File-based route generation
- `@tailwindcss/vite`: Tailwind CSS v4 integration
- `vite-plugin-pwa`: PWA manifest and service worker
- `@julr/vite-plugin-validate-env`: Environment variable validation
- `vite-plugin-checker`: TypeScript checking in dev mode

## Repository Structure

```
vite-react-tailwind-starter/
├── src/
│   ├── lib/
│   │   ├── components/          # Reusable UI components
│   │   │   ├── theme-provider.tsx
│   │   │   └── theme-toggle.tsx
│   │   ├── layout/              # Layout components
│   │   │   ├── components/
│   │   │   │   ├── header.tsx
│   │   │   │   └── footer.tsx
│   │   │   └── index.tsx
│   │   ├── pages/               # Page components
│   │   │   ├── 404/
│   │   │   └── home/
│   │   ├── services/             # Shared services
│   │   │   └── constants.ts
│   │   ├── styles/               # Global styles
│   │   │   └── globals.css
│   │   └── utils/                # Utility functions
│   │       ├── sample.ts
│   │       └── sample.test.ts
│   ├── routes/                   # TanStack Router routes
│   │   ├── __root.tsx           # Root route with layout
│   │   └── index.tsx            # Home route
│   ├── main.tsx                  # Application entry point
│   ├── routeTree.gen.ts         # Auto-generated route tree
│   └── env.d.ts                  # Environment type definitions
├── public/                       # Static assets
├── dist/                         # Build output
├── vite.config.ts                # Vite configuration
├── tsconfig.json                 # TypeScript configuration
├── biome.json                    # Biome linter/formatter config
├── vitest.config.ts              # Vitest test configuration
├── env.ts                        # Environment variable schema
└── package.json
```

## Getting Started

### Prerequisites

- **Node.js**: ^24.11.x (specified in `engines`)
- **pnpm**: 10.24.0 (specified in `packageManager`)

### Installation

You can either click [`Use this template`](https://github.com/agustinusnathaniel/vite-react-tailwind-starter/generate) button on this repository and clone the repo or use npx degit:

```bash
npx degit agustinusnathaniel/vite-react-tailwind-starter <app_name>
cd <app_name>
pnpm install
```

### Development

Start the development server:

```bash
pnpm dev
```

The application will be available at `http://localhost:3000` with HMR enabled.

### Building

Build for production:

```bash
pnpm build
```

Output will be in the `dist/client/` directory.

### Testing

Run tests:

```bash
pnpm test              # Run tests once
pnpm test:ui           # Run tests with UI and coverage
pnpm test:coverage     # Run tests with coverage report
```

### Code Quality

```bash
pnpm biome:check       # Check code style and linting
pnpm biome:fix         # Auto-fix code style issues
pnpm type:check        # TypeScript type checking
pnpm check:turbo       # Run all checks in parallel (biome, type, test)
```

## Configuration

### Environment Variables

Environment variables are validated at build time using Zod. Define your schema in `env.ts`:

```typescript
// env.ts
export default defineConfig({
  schema: {
    VITE_API_BASE_URL: z.string().optional(),
  },
});
```

Access variables in code with type safety:

```typescript
import.meta.env.VITE_API_BASE_URL
```

### TypeScript Paths

Path aliases are configured in `tsconfig.json`:

```json
{
  "paths": {
    "@/*": ["./src/*"]
  }
}
```

Use in imports:

```typescript
import { Layout } from '@/lib/layout';
```

### Tailwind CSS

Tailwind CSS v4 is configured via the `@tailwindcss/vite` plugin. Global styles and customizations are in `src/lib/styles/globals.css`.

### Routing

Routes are defined as files in `src/routes/`. TanStack Router automatically generates the route tree. See [TanStack Router documentation](https://tanstack.com/router) for advanced patterns.

## Deployment

### Build Configuration

- **Build command**: `pnpm build`
- **Output directory**: `dist/client`
- **Node version**: ^24.11.x

### Platform-Specific Guides

- **Vercel**: https://vercel.com/docs/frameworks/vite
- **Netlify**: https://docs.netlify.com/frameworks/vite/
- **Cloudflare Workers**: Configuration in `wrangler.toml`

## Development Workflows

### Adding a New Route

1. Create a file in `src/routes/` (e.g., `src/routes/about.tsx`)
2. Export a `Route` using `createFileRoute`
3. The route tree will auto-regenerate

### Adding a New Page Component

1. Create directory in `src/lib/pages/` (e.g., `src/lib/pages/about/`)
2. Create `index.tsx` with your page component
3. Import and use in the corresponding route file

### Adding Environment Variables

1. Add schema definition in `env.ts`
2. Create `.env` file with your variables (prefixed with `VITE_`)
3. Access via `import.meta.env.VITE_*` with full type safety

### Git Workflow

- **Pre-commit**: Runs Biome formatting/linting on staged files
- **Commit-msg**: Validates commit message format (Conventional Commits)
- **Pre-push**: Runs full check suite (biome, type-check, tests)

## References

- [Vite](https://vitejs.dev)
  - [Avoid manual import](https://vitejs.dev/guide/features.html#jsx)
- [TailwindCSS](https://tailwindcss.com/)
- [TypeScript](https://www.typescriptlang.org)
- [TanStack Router](https://tanstack.com/router)
- [TanStack Query](https://tanstack.com/query)

## License

See [LICENSE](./LICENSE) file.
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。