功能配置
应用持有实例,package 只定义契约
LaunchSaaS 现在不再使用共享的 features 配置文件。
新的原则是:
- package 定义 contract 和类型
- app 构建实际实例
- 组件是否启用由“是否使用组件”决定,而不是全局 feature flag
配置位置
| 领域 | contract 所在位置 | app 实例所在位置 |
|---|---|---|
| Auth | Better Auth + app 本地 wiring | apps/launchsaas/src/lib/auth/ |
| Payment 产品目录 | apps/launchsaas/src/configuration/product/ | apps/launchsaas/src/configuration/product/ |
| Provider 组装 | 各 package provider interface | apps/launchsaas/src/capabilities.ts |
| Cookie 同意组件 | 组件自身 props | 在需要的地方渲染 CookieBanner |
Auth 配置
Auth 现在直接在 apps/launchsaas/src/lib/auth/ 中接线:
auth.ts构建 Better Auth server 实例auth-client.ts构建 Better Auth client- 对应的 OAuth 按钮会在公开 client ID 存在时显示
- 当
CAPTCHA_SECRET_KEY和NEXT_PUBLIC_CAPTCHA_PUBLIC_KEY同时存在时启用 CAPTCHA
Payment 产品配置
产品目录的类型和查找 helper 现在完全归 app 持有:
// apps/launchsaas/src/configuration/product/products.ts
import type { Product } from "./types";
export const products: Product[] = [
{
id: "price_123",
name: "Lifetime Access",
provider: "stripe",
type: "onetime",
sandbox: false,
},
];@launchsaas/payment 仍然只保留 checkout 相关的通用类型,例如 CustomField 和 ProductType;catalog 本身完全位于 apps/launchsaas/src/configuration/product/。定价页产品由 index.ts 里的一个小 helper 按 ID 选择。
Provider 选择
当前使用哪个 email、payment、cache、newsletter、storage、cron provider,由 app 在下面这个文件里显式组装:
// apps/launchsaas/src/capabilities.ts
export const capabilities = {
email: ResendEmailProvider.create(),
// payment 提供商:stripe | creem | polar | dodo | lemonsqueezy
payment: StripePaymentProvider.create(new AppPaymentEventHandler()),
cache: null,
storage: null,
newsletter: null,
cron: null,
};也就是说,不再存在 features.payment.provider 这样的全局切换。
Cookie 同意
Cookie 同意也不再走全局配置。
- 需要同意弹窗,就渲染
CookieBanner - 需要 analytics 等待同意,就给
Analytics传requireCookieConsent - 不需要,就不渲染对应组件
<CookieBanner position="bottom-left" />
<Analytics requireCookieConsent />建议
- 实际 runtime config 一律放在 app
- package 只放可复用 contract/type
- 不要重新引入新的全局
features配置层