react-starter-kit README

The project's README from github.com/kriasoft/react-starter-kit. As one markdown file: README.md.

React Starter Kit

A full-stack monorepo template for building SaaS applications with React 19, tRPC, and Cloudflare Workers. Type-safe from database to UI, deployable to the edge in minutes.

Highlights

React Starter Kit is proudly supported by these amazing sponsors:

    

Technology Stack

Layer Technologies
Runtime Cloudflare Workers
Frontend React 19, TanStack Router, Tailwind CSS v4, shadcn/ui, Jotai
Marketing Astro
Backend Hono, tRPC, Better Auth, Stripe
Database Drizzle ORM, Neon PostgreSQL
Toolchain Bun, TypeScript 7.0, Vite, Vitest, Oxlint, Oxfmt

Monorepo Architecture

├── apps/
│   ├── web/          Astro marketing site (edge router, serves static + proxies to app/api)
│   ├── app/          React 19 SPA (TanStack Router, Jotai, Tailwind CSS v4)
│   ├── api/          Hono + tRPC API server (Better Auth, Cloudflare Workers)
│   └── email/        React Email templates
├── packages/
│   ├── ui/           shadcn/ui components (new-york style)
│   ├── core/         Shared types and utilities
│   └── ws-protocol/  WebSocket protocol with type-safe messaging
├── db/               Drizzle ORM schemas, migrations, and seed data
├── infra/            Terraform (Hyperdrive connection pools, R2 storage)
├── docs/             VitePress documentation
└── scripts/          Build automation and dev tools

Each app deploys independently to Cloudflare Workers. The web worker routes /api/* to the API worker and app routes to the app worker via service bindings.

Prerequisites

Quick Start

1. Create Your Project

Generate a new repository from this template, then clone it locally:

git clone https://github.com/your-username/your-project-name.git
cd your-project-name

2. Install Dependencies

bun install

3. Configure Environment

This project follows Vite env conventions:

cp .env .env.local  # then replace placeholder values with real ones

Also check wrangler.jsonc for Worker configuration and bindings.

4. Start Development

# Launch all apps in development mode (web, api, and app)
bun dev

# Or, start specific apps individually
bun web:dev  # Marketing site
bun app:dev  # Main application
bun api:dev  # API server

5. Initialize Database

Ensure DATABASE_URL is configured in your .env.local file, then set up the schema:

bun db:push              # Push schema directly (quick dev setup)
bun db:seed              # Seed with sample data (optional)
bun db:studio            # Open database GUI

db:push is for local prototyping only. Staging and production apply migrations instead: bun db:migrate:staging, bun db:migrate:production.

App URL
React app http://localhost:5173
Marketing site http://localhost:4321
API server http://localhost:8787

Keep Your Project Updated

When you want to bring in newer React Starter Kit changes, ask your coding agent to run the merge-seed skill (/merge-seed in Claude Code or $merge-seed in Codex). It merges upstream changes while preserving your project's identity and configuration. Start with a clean working tree; the Quick Start guide explains the workflow and its safety boundary.

Production Deployment

The short version. The deployment guide covers each step in full.

1. Provision Infrastructure

Terraform creates the Hyperdrive configurations the API worker connects through:

bun infra:production apply

Paste the two IDs it prints into the hyperdrive block of apps/api/wrangler.jsonc.

2. Environment Setup

Configure your production secrets in Cloudflare Workers:

# Required – the API refuses to deploy without these
bun wrangler secret put BETTER_AUTH_SECRET --config apps/api/wrangler.jsonc --env=""
bun wrangler secret put RESEND_API_KEY --config apps/api/wrangler.jsonc --env=""

# Google sign-in (optional – email OTP and passkeys work without it)
bun wrangler secret put GOOGLE_CLIENT_ID --config apps/api/wrangler.jsonc --env=""
bun wrangler secret put GOOGLE_CLIENT_SECRET --config apps/api/wrangler.jsonc --env=""

# Stripe billing (optional – set all four to enable, or none; annual is extra)
bun wrangler secret put STRIPE_SECRET_KEY --config apps/api/wrangler.jsonc --env=""
bun wrangler secret put STRIPE_WEBHOOK_SECRET --config apps/api/wrangler.jsonc --env=""
bun wrangler secret put STRIPE_STARTER_PRICE_ID --config apps/api/wrangler.jsonc --env=""
bun wrangler secret put STRIPE_PRO_PRICE_ID --config apps/api/wrangler.jsonc --env=""
bun wrangler secret put STRIPE_PRO_ANNUAL_PRICE_ID --config apps/api/wrangler.jsonc --env="" # optional

All of these belong to the API worker, which is what --config selects – without it Wrangler has no worker to attach the secret to. Use --env staging for staging; production is the top-level config, selected explicitly with --env="". Non-sensitive vars like RESEND_EMAIL_FROM go in wrangler.jsonc directly.

Set RESEND_EMAIL_FROM to an address on a domain you have verified with Resend. The default [email protected] only delivers to your own inbox, and sign-in is email OTP – leave it and no one else can sign in.

3. Migrate the Production Database

bun db:migrate:production   # reads .env.production.local, and only that file

4. Build and Deploy

# Builds, then deploys api -> app -> web (service-binding targets first)
bun deploy:staging
bun deploy:production

CI runs the same script, so a release from your machine and one from GitHub Actions cannot drift.

Backers

              

Contributors

                        

Need Help?

Documentation covers auth, database, billing, deployment, and more.

Our AI assistant is trained on this codebase – ask it anything on ChatGPT or Gemini. Try these questions:

Contributing

See the Contributing Guide to get started. Check good first issues or join Discord for discussion.

License

Copyright © 2014-present Kriasoft. This source code is licensed under the MIT license found in the LICENSE file.


Made with ♥ by Konstantin Tarkus (@koistya, blog) and contributors.

react-starter-kit (kriasoft/react-starter-kit)

Searching Database…

这是什么?React Starter Kit 是一个全栈 monorepo 模板,用于构建 SaaS 应用。它把 React 19、tRPC 和 Drizzle ORM 结合在一起,从数据库到界面提供一套类型安全的统一接口,并部署在 Cloudflare Workers 上。
这是我要导入的库,还是我要克隆的项目模板?它是一个 GitHub 模板仓库,你可以基于它生成新项目,它不是库。它是一个 monorepo,包含三个独立的 Cloudflare Workers(web、app、api),通过服务绑定(service bindings)连接在一起。
我该怎么把它跑起来?从 GitHub 模板生成一个新仓库,克隆到本地,运行 bun install,在 .env.local 中填入你的数据库凭据,然后运行开发命令,同时启动三个 Worker。
开始之前需要安装什么?你需要 Bun v1.4 或更新版本,它完全替代了 Node.js 和 npm。另外还需要一个用于部署的 Cloudflare 账户,以及一个作为数据库的 Neon PostgreSQL 连接字符串。
设置数据库时有什么需要注意的坑吗?“bun db:push” 只适合本地原型开发。预发布环境和生产环境必须改用正式的迁移(bun db:migrate:staging / bun db:migrate:production)。
开箱即用的认证和计费功能有哪些?Better Auth 支持邮箱验证码(email OTP)、通行密钥(passkeys)和 Google OAuth,并提供多组织支持。Stripe 已预先接好,可用于订阅计费。
前端技术栈是什么样的?React 19 搭配 TanStack Router 实现基于文件的路由,并使用 TanStack Query 和 Jotai 进行状态管理,另外还有 Tailwind CSS v4 和 shadcn/ui 组件。
数据库是如何设置的?Drizzle ORM 连接到 Neon PostgreSQL,模板中已预先配置好迁移和种子数据。
Creator
kriasoft
Size
34 MB
Stars
23.7K
Age
12y
Commits · 90 Days