Vite + React + TypeScript 的启动器结构,预配置绝对路径导入
vite-react-template — Vite 启动器模板
作者 riipandi
基于 Vite 与 React 的启动器模板,预置 StyleX、TanStack 系列库、Vitest 与 Testing Library,并附带 Storybook 组件浏览与 DummyJSON 演示登录。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
样式使用 StyleX,图标使用 Keyline Icons
集成 TanStack Router、Form、Query、Store、Table、Virtual、Hotkeys、Chart
使用 Vitest 与 React Testing Library 进行测试,Oxlint 与 Oxfmt 负责检查与格式化
附带 Storybook 组件浏览器,演示站点可在线查看
认证基于 DummyJSON API 与 ofetch,采用同源代理和 HttpOnly cookie 会话
模板详细介绍
这是一个面向 React 项目的启动器模板,使用 Vite 构建、TypeScript 编写,样式层采用 StyleX,并集成 TanStack 的 Router、Form、Query、Store、Table、Virtual、Hotkeys、Chart 等库。模板还配置了绝对路径导入、Oxlint 与 Oxfmt 用于代码检查与格式化,以及 Vitest 和 React Testing Library 用于测试。
认证部分通过 ofetch 调用 DummyJSON API,并使用同源代理与 HttpOnly cookie 会话,方便替换成自己的后端。项目附带 Storybook,可在演示站点上浏览组件库。README 说明该模板主要用于作者个人用途,可能遇到 bug,升级前需仔细阅读发布说明。
构建产物是静态 SPA,输出在 .output/build/。基于 cookie 的认证要求同源 API,因此部署时需要选择 Netlify 函数代理、自有后端或反向代理等方式。演示账号为 emilys / emilyspass,勾选 Remember me 可将会话延长至 30 天。
适合你的项目吗?
适用场景
- 快速启动一个使用 Vite 与 React 的新前端项目
- 需要 StyleX 样式方案与 TanStack 全家桶的 React 应用
- 希望以 Storybook 方式浏览和开发 UI 组件的项目
- 需要演示登录流程并计划替换为自有后端的原型
适合人群
- 熟悉 React、TypeScript 与 Vite 的开发者
- 需要预置路由、表单、异步状态与表格等能力的项目
- 希望使用 StyleX 与 Storybook 的团队或个人
- 能接受模板可能包含 bug 并会自行调整的开发者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
使用 npx tiged riipandi/vite-react-template myapp-name 创建项目,并替换 myapp-name
- 2
安装依赖后运行 npm run dev(或 yarn/pnpm 对应命令),应用默认运行在 http://localhost:3000
- 3
演示登录使用 DummyJSON 用户,例如 emilys / emilyspass;勾选 Remember me 可延长会话至 30 天
- 4
Cookie 认证需要同源 API:Netlify 可用内置函数代理,自有后端需设置 PUBLIC_API_URL 并实现 auth 端点,也可用反向代理将 /api 映射到后端
- 5
部署到 Cloudflare Pages 时需设置 NODE_VERSION 为 18.17.1 或 20.9.0,预览分支可设置 PUBLIC_SITE_URL=${CF_PAGES_URL}
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 Apache-2.0 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发;分发时需随附 Apache-2.0 许可证。
- 修改过的文件需显著标明改动,并保留相关版权、专利、商标及归属声明。
- 若原项目附有 NOTICE 文件,分发衍生作品时需保留其中适用的归属声明。
- 许可包含适用的贡献者专利授权;发起许可所述专利诉讼会终止该专利授权,且不授予商标使用权。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 模板的登录认证依赖第三方 DummyJSON 演示 API,并非自带后端;用于真实项目时需替换为自有后端并实现相应认证端点。
- 基于 Cookie 的认证要求同源 API,部署时必须配置 Netlify 函数代理、自有后端或反向代理,否则登录会话无法正常工作。
- 部署到 Cloudflare Pages 时必须在环境变量中设置 NODE_VERSION 为 18.17.1 或 20.9.0,否则构建可能失败。
- 作者声明该模板仅供个人使用,可能存在 bug,不保证生产可用性;使用前需自行评估与测试。
- 升级前必须仔细阅读发布说明,因为版本更新可能引入破坏性变更。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 Apache-2.0 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
no-charge, royalty-free, irrevocable copyright license
许可证原文
Authentication is implemented using [DummyJSON](https://dummyjson.com) API
README 原文
Cookie auth needs a same-origin API.
README 原文
You need to add `NODE_VERSION` with value `18.17.1` or `20.9.0` on the environment variables setting.
README 原文
This project just a template that I use for my personal use, so you may encounter bugs.
README 原文
https://github.com/riipandi/vite-react-template/blob/main/LICENSE-APACHEhttps://github.com/riipandi/vite-react-template/blob/main/README.mdPlease review the release notes thoroughly before updating, as breaking changes can occur!
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 92 / 100
- 技术栈
- Vite · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-09-21
- 截图检查日期
- 2026-10-03
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Vite。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: [email protected] · 2026-10-04
查看当时使用的来源资料
SHA-256: b27202598bc3acfb5a37616c200be61716c2fb46a6007e4b0f86a6535c2b48db
2026-10-03T19:16:21.503Z
来源文件 / 仓库<p align="center"><img src="./public/images/vite.svg" width="500" height="120" alt="Project Logo"></p>
<p align="center">
<a href="https://github.com/riipandi/vite-react-template/pulse">
<img src="https://img.shields.io/badge/Contributions-welcome-blue.svg?style=flat-square" alt="Contribution welcome">
</a>
<a href="https://github.com/riipandi/vite-react-template">
<img src="https://img.shields.io/github/languages/top/riipandi/vite-react-template?style=flat-square" alt="Top language">
</a>
<a href="https://aris.mit-license.org">
<img src="https://img.shields.io/github/license/riipandi/vite-react-template?style=flat-square" alt="License">
</a>
<a href="https://app.netlify.com/sites/reactivite/deploys">
<img src="https://api.netlify.com/api/v1/badges/47668315-f674-4560-8f83-52852dae2593/deploy-status" alt="Netlify Status">
</a>
</p>
## Introduction
A starter project for [React](https://reactjs.org/) with [Vite](https://vitejs.dev/), [StyleX](https://stylexjs.com),
and [Typescript](https://www.typescriptlang.org/). This starter kit is already pre-configured
and [Typescript](https://www.typescriptlang.org/). This starter kit is already pre-configured
with [absolute import](https://jsdev.org/env/nodejs/absolute-path-imports/), [TanStack Router](https://tanstack.com/router),
[TanStack Form](https://tanstack.com/form), [TanStack Query](https://tanstack.com/query),
[TanStack Store](https://tanstack.com/store), [Oxlint](https://oxc.rs/docs/guide/usage/linter),
and [other goodies](./package.json). Authentication is implemented using [DummyJSON](https://dummyjson.com) API
with [ofetch](https://github.com/unjs/ofetch), easily replaceable with your own backend.
Browse the component library live in [Storybook](https://reactivite.netlify.app/storybook/).
> [!NOTE]
> This project just a template that I use for my personal use, so you may encounter bugs.
> Please review the release notes thoroughly before updating, as breaking changes can occur!
## The Complete Stack
- [x] [Vite](https://vitejs.dev/) - Next Generation Frontend Tooling.
- [x] [React](https://reactjs.org) - A JavaScript library for building user interfaces.
- [x] [StyleX](https://stylexjs.com) - The styling system for ambitious user interfaces.
- [x] [Keyline Icons](https://github.com/keyline-icons/keyline-icons) - Consistent 24×24 stroke, duotone, and fill icons.
- [x] [Typescript](https://www.typescriptlang.org) - Strongly typed programming language.
- [x] [TanStack Router](https://tanstack.com/router) - Type-safe routing for React.
- [x] [TanStack Form](https://tanstack.com/form) - Headless, type-safe form state management.
- [x] [TanStack Query](https://tanstack.com/query) - Powerful asynchronous state management.
- [x] [TanStack Store](https://tanstack.com/store) - Lightweight, type-safe state management.
- [x] [TanStack Table](https://tanstack.com/table) - A powerful engine for building Data Grids.
- [x] [TanStack Virtual](https://tanstack.com/virtual) - A headless UI utility for virtualizing long lists of elements.
- [x] [TanStack Hotkeys](https://tanstack.com/hotkeys) - A type-safe, framework-agnostic library for handling keyboard shortcuts.
- [x] [TanStack Chart](https://tanstack.com/charts) - A typed, tree-shakable chart grammar for SVG and Canvas.
- [x] [React Testing Library](https://testing-library.com/) - Light-weight solution for testing React components.
- [x] [Vitest](https://vitest.dev/) - Blazing Fast Unit Test Framework.
- [x] [Oxlint](https://oxc.rs/docs/guide/usage/linter) - High-performance JavaScript linter.
- [x] [Oxfmt](https://oxc.rs/docs/guide/usage/formatter) - High-performance code formatter.
- [x] [Storybook](https://storybook.js.org/) - UI component explorer for frontend developers.
## Quick Start
### Installation
```bash
npx tiged riipandi/vite-react-template myapp-name
```
> Don't forget to change `myapp-name` with your real application name.
### Up and Running
| NPM | Yarn | PNPM | Description |
|-------------------|----------------|----------------|--------------------------|
| `npm install` | `yarn` | `pnpm install` | install the dependencies |
| `npm run dev` | `yarn dev` | `pnpm dev` | serve with hot reload |
| `npm run build` | `yarn build` | `pnpm build` | build for production |
| `npm run preview` | `yarn preview` | `pnpm preview` | launch generated build |
Application will run at `http://localhost:3000`
For detailed explanation on how things work, check out [Vite documentation](https://vitejs.dev/guide).
### Demo Account
Authentication hits the [DummyJSON](https://dummyjson.com) API through a same-origin proxy,
using HttpOnly cookie sessions. Use any valid [DummyJSON user](https://dummyjson.com/users) to sign in, e.g.:
| Username | Password |
|----------|--------------|
| `emilys` | `emilyspass` |
Tick **Remember me** to extend the session lifetime to 30 days.
> [!IMPORTANT]
> Cookie auth needs a same-origin API. `pnpm dev`, `pnpm preview`, and `pnpm start`
> all ship with the same-origin proxy (`start`/`preview` serve the production
> build via Vite). See [Deploying the SPA](#deploying-the-spa).
## Deploy your own
Fork this repository, connect it to Netlify, and pushing to master will deploy to production! 🚀
<p>
<a href="https://vercel.com/new/clone?repository-url=https://github.com/riipandi/vite-react-template&project-name=vite-react-template&repo-name=my-vite-react-app&env=PUBLIC_SITE_URL">
<img src="https://vercel.com/button" alt="Deploy to Vercel" height="32" />
</a>
<a href="https://app.netlify.com/start/deploy?repository=https://github.com/riipandi/vite-react-template">
<img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify" height="32" />
</a>
<a href="https://deploy.workers.cloudflare.com/?url=https://github.com/riipandi/vite-react-template">
<img src="https://deploy.workers.cloudflare.com/button" alt="Deploy to Cloudflare" height="32" />
</a>
</p>
### Deploying the SPA
The build output is a static SPA (`.output/build/`). Cookie-based auth requires a **same-site API** —
browsers do not send `SameSite=Lax` cookies on cross-site requests. Pick one:
- **Netlify** — works out of the box: [`netlify/functions/api.ts`](./netlify/functions/api.ts)
transparently proxies every `/api/*` request (all HTTP methods) to the demo backend on the
site's own origin, so the HttpOnly session cookies stick. The deploy also publishes
Storybook under `/storybook/` (relative asset URLs, no extra base config needed).
- **Own backend** (recommended for production) — set `PUBLIC_API_URL` to your API on the same
parent domain (e.g. `https://api.example.com`) and implement the auth endpoints
(`POST /auth/login`, `GET /auth/me`, `POST /auth/refresh`, `POST /auth/logout`,
`GET /auth/session`).
- **Reverse proxy** — map `/api` to your backend server-side (nginx, Caddy, …) and keep
`PUBLIC_API_URL=/api`.
### Cloudflare Deployment
You need to add `NODE_VERSION` with value `18.17.1` or `20.9.0` on the environment variables setting.
Visit [Cloudflare pages docs](https://developers.cloudflare.com/pages/platform/build-configuration/)
for more information.
For the preview branch:
```env
PUBLIC_SITE_URL=${CF_PAGES_URL}
```
## Development
This project uses TypeScript for type checking, [Oxlint](https://oxc.rs/docs/guide/usage/linter) for linting
and [Oxfmt](https://oxc.rs/docs/guide/usage/formatter) for code formatting which are configured in
[`.oxlintrc.json`](./.oxlintrc.json) and [`.oxfmtrc.json`](./.oxfmtrc.json). It's recommended
to get TypeScript set up for your editor and install an editor plugin (like the
[VSCode Oxc plugin](https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode)) to get
auto-formatting on saving and get a really great in-editor experience with type checking and auto-complete.
## Thanks to
In general, I'd like to thank every single one who open-sources their source code for their effort
to contribute something to the open-source community. Your work means the world! 🌍 ❤️
### Attribution
- [MadeUI](https://madeui.com/) — the Base UI + StyleX components in this template are based on its components.
- [Reshaped](https://www.reshaped.so/) — the design system in this template is built on its design system.
- [ReUI](https://reui.io) — the Data Grid, Input Phone, Sortable, and Kanban components are ports of ReUI.
- [Flavio Copes](https://flaviocopes.com/stylex) - A deep dive into StyleX.
## Notice
Why using web workers for auth? [Keep React Responsive with Web Workers and useRef](https://reactdevelopment.substack.com/p/keep-react-responsive-with-web-workers)
## License
Licensed under either of [Apache License 2.0][license-apache] or [MIT license][license-mit] at your option.
> Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you,
> as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Copyrights in this project are retained by their contributors.
See the [LICENSE-APACHE](./LICENSE-APACHE) and [LICENSE-MIT](./LICENSE-MIT) files for more information.
---
<sub>🤫 Psst! If you like my work you can support me via [GitHub sponsors](https://github.com/sponsors/riipandi).</sub>
<!-- link reference definition -->
[license-mit]: https://choosealicense.com/licenses/mit/
[license-apache]: https://choosealicense.com/licenses/apache-2.0/
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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 · 启动器
