
关于
从零开始规划或构建 SaaS MVP 时使用。提供涵盖技术栈、架构、核心功能和上市策略的结构化路线图。
name: saas-mvp-launcher description: "用于从零开始规划或构建 SaaS MVP。提供涵盖技术栈、架构、认证、支付和上线检查清单的结构化路线图。" risk: safe source: community date_added: "2026-03-04"
SaaS MVP 启动器
概述
此技能指导你在最短时间内构建一个生产就绪的 SaaS MVP。涵盖从创意验证和技术栈选择到认证、支付、数据库设计、部署和上线的所有内容——使用现代、经过实战检验的工具。
适用场景
- 从零开始一个新的 SaaS 产品时使用
- 需要为 Web 应用选择技术栈时使用
- 为 SaaS 设置认证、计费或数据库时使用
- 需要上线前的结构化检查清单时使用
- 设计多租户应用架构时使用
- 对现有早期 SaaS 进行技术审查时使用
分步指南
1. 先验证再构建
在写任何代码之前,验证想法:
Validation checklist:
- [ ] Can you describe the problem in one sentence?
- [ ] Who is the exact customer? (not "everyone")
- [ ] What do they pay for today to solve this?
- [ ] Have you talked to 5+ potential customers?
- [ ] Will they pay $X/month for your solution?
规则: 如果你无法让 3 个人预付或签署意向书,先不要构建。
2. 选择技术栈
推荐的现代 SaaS 技术栈(2026):
| 层级 | 选择 | 原因 | |-------|--------|-----| | 前端 | Next.js 15 + TypeScript | 全栈,优秀的开发体验,Vercel 部署 | | 样式 | Tailwind CSS + shadcn/ui | 快速、无障碍、可定制 | | 后端 | Next.js API Routes 或 tRPC | 类型安全,代码共置 | | 数据库 | PostgreSQL via Supabase | 可靠、可扩展、免费层 | | ORM | Prisma 或 Drizzle | 类型安全查询、迁移 | | 认证 | Clerk 或 NextAuth.js | 社交登录、会话管理 | | 支付 | Stripe | 行业标准,文档优秀 | | 邮件 | Resend + React Email | 现代、开发者友好 | | 部署 | Vercel(前端)+ Railway(后端) | 零配置、快速 CI/CD | | 监控 | Sentry + PostHog | 错误追踪 + 分析 |
3. 项目结构
my-saas/
├── app/ # Next.js App Router
│ ├── (auth)/ # Auth routes (login, signup)
│ ├── (dashboard)/ # Protected app routes
│ ├── (marketing)/ # Public landing pages
│ └── api/ # API routes
├── components/
│ ├── ui/ # shadcn/ui components
│ └── [feature]/ # Feature-specific components
├── lib/
│ ├── db.ts # Database client (Prisma/Drizzle)
│ ├── stripe.ts # Stripe client
│ └── email.ts # Email client (Resend)
├── prisma/
│ └── schema.prisma # Database schema
├── .env.local # Environment variables
└── middleware.ts # Auth middleware
4. 核心数据库 Schema(多租户 SaaS)
model User {
id String @id @default(cuid())
email String @unique
name String?
createdAt DateTime @default(now())
subscription Subscription?
workspaces WorkspaceMember[]
}
model Workspace {
id String @id @default(cuid())
name String
slug String @unique
plan Plan @default(FREE)
members WorkspaceMember[]
createdAt DateTime @default(now())
}
model Subscription {
id String @id @default(cuid())
userId String @unique
user User @relation(fields: [userId], references: [id])
stripeCustomerId String @unique
stripePriceId String
stripeSubId String @unique
status String # active, canceled, past_due
currentPeriodEnd DateTime
}
enum Plan {
FREE
PRO
ENTERPRISE
}
5. 认证设置(Clerk)
// middleware.ts
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
const isPublicRoute = createRouteMatcher([
'/',
'/pricing',
'/blog(.*)',
'/sign-in(.*)',
'/sign-up(.*)',
'/api/webhooks(.*)',
]);
export default clerkMiddleware((auth, req) => {
if (!isPublicRoute(req)) {
auth().protect();
}
});
export const config = {
matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
};
6. Stripe 集成(订阅)
// lib/stripe.ts
import Stripe from 'stripe';
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: '2025-01-27.acacia',
});
// Create checkout session
export async function createCheckoutSession(userId: string, priceId: string) {
return stripe.checkout.sessions.create({
mode: 'subscription',
payment_method_types: ['card'],
line_items: [{ price: priceId, quantity: 1 }],
success_url: `${process.env.NEXT_PUBLIC_URL}/dashboard?success=true`,
cancel_url: `${process.env.NEXT_PUBLIC_URL}/pricing`,
metadata: { userId },
});
}
兼容工具
Claude CodeCursor
标签
SaaS
