同时覆盖两种形态:自有域名上的 OAuth 应用,以及嵌入 civitai.com 的 iframe 应用
civitai-app-starters — Next.js 启动器模板
作者 civitai
Civitai 官方提供的启动模板与共享 SDK,用于构建第三方 Civitai 应用:既支持自有域名上的 OAuth 应用,也支持嵌入 civitai.com 页面的 iframe 应用。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
提供 Next.js、SvelteKit、React PWA、Svelte PWA 四个 OAuth 启动模板,演示界面一致
@civitai/app-sdk 封装 OAuth + PKCE、加密 Cookie 会话、scope 助手与 orchestrator 调用
@civitai/app-sdk/blocks 定义框架无关的 manifest 与 postMessage 协议,@civitai/blocks-react 提供 React hooks 与 iframe 传输
starters/examples 下有六个按功能划分的可运行示例,每个都能通过模拟宿主的 dev harness 离线运行
附带 PORTING.md 与 AGENTS.md,分别说明如何把 SDK 接入既有应用、以及 AI 编码代理应遵循的约定
模板详细介绍
该仓库面向两类 Civitai 第三方应用。第一类是 OAuth 应用:部署在开发者自己的域名上,通过 Civitai 登录并调用 orchestrator,仓库提供 Next.js、SvelteKit、React PWA、Svelte PWA 四个 starters 模板,以及负责 OAuth + PKCE、加密 Cookie 会话、scope 助手与 orchestrator 调用封装的 @civitai/app-sdk。第二类是 Civitai Apps:以 iframe 形式渲染在 civitai.com 页面内(例如模型侧边栏中的生成器),由 @civitai/app-sdk 的 /blocks 子路径提供框架无关的 manifest 与 postMessage 协议,@civitai/blocks-react 提供 React hooks 与 iframe 传输层,并配有六个可离线运行的最小示例。
四个 OAuth 模板共用同一套最小演示:Civitai OAuth 登录、读取并显示 Buzz 余额(通过 fetchBuzzAccount(),未授予 BuzzRead 时隐藏)、以 whatif 预览一次生成的成本、提交一次图像生成并展示结果。PWA 模板通过一个轻量 Hono BFF 完成令牌交换,因此客户端类型仍为 Confidential。
Civitai Apps 的脚手架与提交由 Go 编写的 civitai CLI 负责(login / app init / validate / submit),本地开发使用项目自带的 dev:harness 或 dev:live。提交后由平台在审核通过时注入构建配方并托管 dist/,开发者不需要提供 Dockerfile 或 nginx.conf,也不自行设置 iframe.src。仓库同时包含 PORTING.md(将 SDK 接入既有应用的步骤)与 AGENTS.md(面向 AI 编码代理的约定)。
适合你的项目吗?
适用场景
- 在自有域名上搭建一个使用 Civitai 登录、可调用 orchestrator 生成图像的 Web 应用
- 开发需要被搜索引擎收录的 Civitai 第三方站点(选择 next-app 或 sveltekit-app)
- 开发工具、小游戏或界面聚焦、无需 SEO 的 SPA/PWA(选择 react-pwa 或 svelte-pwa)
- 构建渲染在 civitai.com 页面内的 iframe 应用,例如模型侧边栏中的生成器
- 为已有应用增加 Sign-in-with-Civitai,或把图像生成后端替换为 Civitai orchestrator
适合人群
- 需要以 Civitai 账号登录并调用其 orchestrator 的第三方应用开发者
- 希望在 civitai.com 页面内嵌入小型交互界面的开发者
- 使用 Next.js、SvelteKit、React 或 Svelte 技术栈的团队
- 需要参考最小可运行示例来理解 Buzz 计费、scope 与存储等接口的开发者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
推荐用 npx tiged civitai/civitai-app-starters/starters/<模板名> 只拉取所需模板,而非克隆整个 monorepo
- 2
在 civitai.com/user/account 的 OAuth Apps 中创建应用,客户端类型选 Confidential,并把 CIVITAI_CLIENT_ID 与 CIVITAI_CLIENT_SECRET 写入 .env
- 3
回调地址默认为 http://localhost:3000/api/auth/callback/civitai,各模板可能不同,需查看对应 README
- 4
仓库要求 Node ≥ 20 并使用 pnpm;monorepo 自身可用 pnpm build、pnpm test、pnpm typecheck
- 5
Civitai Apps 的脚手架与提交依赖 Go 编写的 civitai CLI,本地开发使用项目自带的 dev:harness 或 dev:live
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中的免费 MIT 版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 使用、修改或分发代码时,保留原作者版权声明和完整 MIT 许可证。
- 允许免费使用、修改及商用,也允许分发代码;分发时仍需随附版权与许可声明。
- 代码按现状提供,作者不承诺担保或承担使用责任。
额外费用与待核对事项
- Civitai Apps 的脚手架、校验与提交依赖仓库外部的 Go 版 civitai CLI(github.com/civitai/cli),并非本仓库自带;使用该形态需另行安装该外部工具。
- OAuth 模板运行前必须在 civitai.com 注册 OAuth 应用,并取得 CIVITAI_CLIENT_ID 与 CIVITAI_CLIENT_SECRET 填入 .env,否则无法登录与调用 orchestrator。
- 需要 Civitai 账号及 OAuth 客户端凭据(client id/secret)才能运行模板;这些凭据由 Civitai 平台签发,属于外部服务依赖。
- Civitai Apps 提交后须经平台人工审核,审核通过才会构建与部署;被拒时无法上线,发布流程受平台审核约束。
- Civitai Apps 的构建与托管由 Civitai 平台完成,最终部署在 https://<blockId>.civit.ai/ 域名下,开发者无法自行选择托管方式或域名。
- 运行时镜像与 iframe.src 由平台控制,开发者不能自带 Dockerfile/nginx.conf 或自行设置 iframe.src,部署配置自由度受限。
- 本地开发时 dev harness 固定父页面 origin,必须以匹配的 origin 提供服务,否则 BLOCK_INIT 被拒、应用会卡在加载状态。
- 使用 Buzz 计费时,估算与提交必须构造完全一致的参数(尤其是 seed),否则报价的 Buzz 成本与实际扣费不符。
- Buzz 余额只能通过 fetchBuzzAccount() 读取,且需已授予 BuzzRead scope;未授权时余额界面会被完全隐藏。
- iframe 应用需自行在根元素设置 data-theme,宿主无法注入;否则所有 [data-theme="dark"] 样式不会生效。
- 当前 PWA 模板仍需 Confidential 客户端与 BFF 持有密钥;纯浏览器公共客户端流程尚未提供,仅列在路线图中。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
Go **`civitai` CLI** ([github.com/civitai/cli](https://github.com/civitai/cli)): `civitai login` → `civitai app init` / `civitai app validate` / `civitai app submit`.
README 原文
Go to [civitai.com/user/account](https://civitai.com/user/account) → **OAuth Apps** → **Create**.
README 原文
Copy `CIVITAI_CLIENT_ID` and `CIVITAI_CLIENT_SECRET` into `.env`.
README 原文
**Review** — a moderator reviews the manifest + file diff at **`/apps/review`** and approves (or rejects with a reason you see on `/apps/build`).
README 原文
**Deploy** — on approve, the platform builds + serves your `dist/` and stamps the block's `iframe.src` server-side, serving it at **`https://<blockId>.civit.ai/`** (root-served).
README 原文
**The platform owns the runtime image + `iframe.src`** — you don't ship a `Dockerfile`/`nginx.conf` or set `iframe.src`; the platform injects the build and stamps the src
README 原文
**The dev harness pins the parent origin** — serve on the matching origin or `BLOCK_INIT` is rejected and the block hangs on "Loading…".
README 原文
**Your estimate must build params identically to submit** (esp. the seed) or the quoted Buzz cost won't match the charge.
README 原文
show your Buzz balance (read with `fetchBuzzAccount()` — **not** from `/api/v1/me`, which returns none; hidden entirely when `BuzzRead` was not granted)
README 原文
**Set `data-theme` on your own root** — the host can't inject it into your iframe, so any `[data-theme="dark"]` CSS is dormant until you do.
README 原文
https://github.com/civitai/civitai-app-starters/blob/main/LICENSEhttps://github.com/civitai/civitai-app-starters/blob/main/README.md(Public-client browser-only flow is on the roadmap for a future `*-static` variant.)
README 原文
依据完整 MIT 许可证与仓库 README 核对 · 2026-09-29。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 88 / 100
- 技术栈
- Next.js · Svelte · React
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-09-28
- 截图检查日期
- 2026-09-29
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 75e66c0067d12ea66c124492b2ad7a007e3566901d57fd5fe8ce7803f22aea4a
2026-09-29T01:06:21.065Z
来源文件 / 仓库# Civitai App Starters
[](https://github.com/civitai/civitai-app-starters/actions/workflows/ci.yml)
[](./LICENSE)
[](https://nodejs.org)
[](https://pnpm.io)
[](https://www.npmjs.com/package/@civitai/app-sdk)
Starter templates for building on [Civitai](https://civitai.com), plus the shared SDK packages they use. Two product surfaces live here:
1. **OAuth apps** — full apps on your own domain that sign in with Civitai and
call the orchestrator. The four `starters/*` templates + `@civitai/app-sdk`.
2. **Civitai Apps** — iframe-embedded UIs that render *inside* civitai.com pages
(e.g. a generator in a model's sidebar). The `@civitai/app-sdk/blocks`
contract + `@civitai/blocks-react` hooks + the runnable
[`starters/examples/*`](./starters/examples). **See [Civitai Apps](#civitai-apps)
below.**
## What's in here
- **`packages/civitai-app-sdk`** — OAuth + PKCE, encrypted-cookie sessions, scope helpers, orchestrator-call helpers, AND the framework-agnostic **Civitai Apps** contract (`/blocks` subpath). Published to npm as `@civitai/app-sdk`.
- **`packages/civitai-blocks-react`** — React hooks + iframe transport for Civitai Apps. Published as `@civitai/blocks-react`.
- **Scaffolding + submit for Civitai Apps** — handled by the Go **`civitai` CLI** ([github.com/civitai/cli](https://github.com/civitai/cli)): `civitai login` → `civitai app init` / `civitai app validate` / `civitai app submit`. (Local dev is the scaffolded project's own `npm run dev:harness` / `npm run dev:live`.) The old `@civitai/blocks-cli` npm scaffolder it replaced stays published-but-deprecated on npm but is no longer part of this repo.
- **`starters/next-app`** — Next.js 15 (App Router) + Tailwind. SSR-friendly, SEO-capable. Best OAuth-app default.
- **`starters/sveltekit-app`** — SvelteKit 2 + Tailwind. Same demo surface as `next-app`.
- **`starters/react-pwa`** — Vite + React 19 + tiny Hono BFF for OAuth token exchange. SPA/PWA shape.
- **`starters/svelte-pwa`** — Vite + bare Svelte 5 (no Kit) + tiny Hono BFF. SPA/PWA shape.
- **`starters/civitai-block-starter`** — Vite + React 19 Civitai App scaffold.
- **`starters/examples/*`** — six minimal, runnable Civitai App examples, one per feature (see [Civitai Apps](#civitai-apps)).
The four OAuth starters ship the **same minimal demo:** log in via Civitai OAuth → show your Buzz balance (read with `fetchBuzzAccount()` — **not** from `/api/v1/me`, which returns none; hidden entirely when `BuzzRead` was not granted) → preview cost of a generation (`whatif`) → submit one image generation → display the result.
## Pick a starter
| Need | Use |
|---|---|
| Discoverable via search engines | `next-app` (default) or `sveltekit-app` |
| Tool, mini-game, focused UI, no SEO | `react-pwa` or `svelte-pwa` |
| Don't know / mainstream stack | `next-app` |
## Clone just one starter (recommended)
You almost never want to clone the whole monorepo. Pull just the starter you need:
```bash
npx tiged civitai/civitai-app-starters/starters/next-app my-app
cd my-app
cp .env.example .env
pnpm install
pnpm dev
```
Then:
1. Go to [civitai.com/user/account](https://civitai.com/user/account) → **OAuth Apps** → **Create**.
2. For SSR starters (`next-app`, `sveltekit-app`): client type **Confidential**.
3. For PWA starters (`react-pwa`, `svelte-pwa`): client type **Confidential** still — the BFF holds the secret. (Public-client browser-only flow is on the roadmap for a future `*-static` variant.)
4. Redirect URI: `http://localhost:3000/api/auth/callback/civitai` (varies per starter — see each starter's README).
5. Copy `CIVITAI_CLIENT_ID` and `CIVITAI_CLIENT_SECRET` into `.env`.
6. `pnpm dev`.
## Alternative ways to clone
```bash
# Next.js CLI native
npx create-next-app --example "https://github.com/civitai/civitai-app-starters/tree/main/starters/next-app" my-app
# Full repo + sparse-checkout (if you want git history)
git clone --filter=blob:none --sparse https://github.com/civitai/civitai-app-starters
cd civitai-app-starters && git sparse-checkout set --cone starters/next-app
```
## Civitai Apps
A **Civitai App** is a small iframe-embedded UI that renders inside a civitai.com
page — for example, a generator in a model's sidebar (`model.sidebar_top` slot).
Unlike an OAuth app, a block runs *inside* civitai.com and gets a short-lived,
block-scoped JWT + page context handed to it via `postMessage`. It's much smaller
than a full app: a single static SPA, no OAuth dance, no BFF.
### Packages
| Package | What |
|---|---|
| [`@civitai/app-sdk`](https://www.npmjs.com/package/@civitai/app-sdk) (`/blocks` subpath) — [source](./packages/civitai-app-sdk) | Framework-agnostic contract: manifest types, scopes, the `postMessage` protocol. Build-time manifest validation (`defineBlock`, `blockManifestPlugin`) lives on the node-only `/manifest` and `/vite` subpaths. |
| [`@civitai/blocks-react`](https://www.npmjs.com/package/@civitai/blocks-react) — [source](./packages/civitai-blocks-react) | React hooks (`useBlockContext`, `useBuzzWorkflow`, `useAppStorage`, …) + iframe transport. Plus `/ui` (the `SettingsForm`). |
| Go [`civitai` CLI](https://github.com/civitai/cli) | `civitai login` / `civitai app init` / `civitai app validate` / `civitai app submit` — scaffold and ship a block. (Local dev is the project's own `npm run dev:harness`.) Replaces the deprecated `@civitai/blocks-cli`. |
### Examples (start here)
Six minimal, runnable blocks under [`starters/examples/`](./starters/examples) —
one per feature, each with its own README. Each runs offline via a dev harness
that simulates the host.
| Example | Shows |
|---|---|
| [`hello-world`](./starters/examples/hello-world) | lifecycle: `useBlockContext`, the host trust frame, self-set `data-theme` |
| [`settings`](./starters/examples/settings) | manifest `settings` + the headless `SettingsForm`, publisher vs viewer scopes |
| [`buzz-workflow`](./starters/examples/buzz-workflow) | `useBuzzWorkflow` estimate→submit→poll, the cost-quote-matches-charge rule |
| [`kv-storage`](./starters/examples/kv-storage) | `useAppStorage` get/set/delete/list/getQuota |
| [`scopes-api`](./starters/examples/scopes-api) | declaring scopes + calling scope-gated REST with the BLOCK_INIT token |
| [`buzz-purchase`](./starters/examples/buzz-purchase) | `useBuzzPurchase` + the insufficient-budget flow |
### The dev → submit → review → deploy lifecycle
Devs never touch git hosting. The path is:
1. **Auth + Build** — `civitai login` once, scaffold with `civitai app init`,
iterate locally with `npm run dev:harness` (mock host) or `npm run dev:live`
(live host), `vite build` to a static `dist/`. Validate the manifest any time
with `civitai app validate`.
2. **Submit** — `civitai app submit` validates, packages your project
(`block.manifest.json` + `src/` + `index.html` + `package.json` +
`vite.config.ts` + …), and uploads it for review with your stored token. You
don't include a `Dockerfile` or `nginx.conf` — the platform injects its own
build recipe at approve. (If you have no token configured, `submit` writes the
`.zip` and prints next steps; you can also web-upload at `/apps/submit`.)
3. **Review** — a moderator reviews the manifest + file diff at **`/apps/review`**
and approves (or rejects with a reason you see on `/apps/build`).
4. **Deploy** — on approve, the platform builds + serves your `dist/` and stamps
the block's `iframe.src` server-side, serving it at
**`https://<blockId>.civit.ai/`** (root-served). Within ~5 min your block is
live in its slot.
→ **[Build your first App](./docs/build-your-first-app-block.md)** — the
end-to-end guide, from `civitai app init` to a live block.
### Gotchas worth knowing up front
These bit us building the reference block; the examples + the guide bake in the fixes:
- **Set `data-theme` on your own root** — the host can't inject it into your
iframe, so any `[data-theme="dark"]` CSS is dormant until you do.
- **Your estimate must build params identically to submit** (esp. the seed) or
the quoted Buzz cost won't match the charge.
- **The platform owns the runtime image + `iframe.src`** — you don't ship a
`Dockerfile`/`nginx.conf` or set `iframe.src`; the platform injects the build
and stamps the src (`https://<blockId>.civit.ai/`, root-served) at approve.
Keep Vite `base: '/'` so the bundle resolves its own assets at the root.
- **The dev harness pins the parent origin** — serve on the matching origin or
`BLOCK_INIT` is rejected and the block hangs on "Loading…".
## Porting an existing app
Already have an app and want to **add Sign-in-with-Civitai** or **swap your image-gen provider** for Civitai's orchestrator? See [`PORTING.md`](./PORTING.md) — step-by-step recipe for grafting the SDK into an existing codebase, with notes on both additive ("Civitai as one more provider") and full-replacement integration modes.
## For AI coding agents
See [`AGENTS.md`](./AGENTS.md) at the root and the per-starter `AGENTS.md` inside each `starters/*`. The agent guides document which patterns to keep (auth + SDK lives in `@civitai/app-sdk`), which to avoid (don't put `client_secret` in the browser), and how the demo surface is structured.
## Working on the monorepo itself
```bash
pnpm install
pnpm build # build all workspace packages
pnpm test # run all package tests
pnpm typecheck # type-check everything
```
### Releasing the SDK
`@civitai/app-sdk` ships via changesets + a GitHub Actions workflow with npm OIDC. After changing the SDK:
```bash
pnpm changeset # author a changeset (patch / minor / major)
pnpm changeset status # preview pending bumps
```
Merge the auto-opened *Version Packages* PR to publish. Full guide: [`RELEASING.md`](./RELEASING.md).
## License
[MIT](./LICENSE)
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

ai-website-cloner-template
Clone any website with one command using AI coding agents
Next.js · 启动器

Next.js SaaS Starter
Next.js SaaS Starter 是 Next.js 官方维护的 SaaS 起点模板,定位介于学习资源和可直接部署的脚手架之间。
Next.js · SaaS

Next.js Commerce
Next.js Commerce 是 Vercel 团队维护的电商启动模板,基于 Next.js App Router 构建,采用服务端渲染、React Server Components、Server Actions …
Next.js · 电商

Next-js-Boilerplate
Next-js-Boilerplate 是一个面向 Next.js 16、Tailwind CSS 4 和 TypeScript 的启动器,核心定位是开发者体验优先。
Next.js · 启动器

tailwind-nextjs-starter-blog
tailwind-nextjs-starter-blog 是一个面向个人技术博客的 Next.js 与 Tailwind CSS 启动模板,其 v2 版本基于 App Router 与 React Server Comp…
Next.js · 博客

next-forge
Production-grade Turborepo template for Next.js apps.
Next.js · 启动器
