@12-apps/onboarding

中文文档
2.7.0发布于 2026/08/25MITTypeScriptES Module构建来源已验证近 30 天下载 3.3万

Reusable guided onboarding: React provider + GuidedSection and the API-bound OnboardingStore (.), the host-mounted progress surface (./server: createApiOnboarding — GET/PATCH progress with save/dismiss/reset), a Hono adapter (./hono), and the package-owne

原始使用文档
文档目录3 节
  1. Exports
  2. The data model comes with the package
  3. Wiring

@12-apps/onboarding

Reusable, resumable, per-user×tenant onboarding progress for guided setup flows — one small system any app/page can adopt.

  • Persists exactly which step a user stopped on and an opaque per-feature payload, so a refresh resumes them where they left off (not the start).
  • Persistence-agnostic: the UI + hook talk to an injected OnboardingStore, so you back it with Prisma server actions, tRPC, REST, or anything.
  • Ships a Prisma helper (createOnboardingRepository) for the common case, and a GuidedSection UI that binds the state to @12-apps/ui's SectionOnboarding + stepper.

Both halves ship here (12-23): the screens AND the endpoints they persist through, one factory each. ADOPTING.md is the adoption contract — the config table, the wiring rules that bite, and the Phase B notes for a host that already has the table.

Exports

EntryExportWhat
.OnboardingProvider / useOnboardingClient state, mutations through an injected OnboardingStore.
.GuidedSectionLanding hero → per-step wizard (stepper) → completed summary, driven by the persisted state.
.createOnboardingApiStore / fetchOnboardingStateThe store bound to the package's OWN endpoints, so the URL, the body shape and the date revival are stated once instead of in every host.
.typesOnboardingStore, OnboardingStateSnapshot, GuidedStep, GuidedNav, …
./servercreateApiOnboarding({ db })The progress surface as framework-neutral route descriptors — GET and PATCH with save / dismiss / reset.
./servercreateOnboardingRepository(getPrisma)The Prisma read/write helper under it (data-merge + started/completed stamping).
./honoonboardingRouter({ db, resolveActor })The same surface as a mountable Hono router. hono is an OPTIONAL peer.
prisma/onboarding.prisma + its migrationThe package OWNS the OnboardingState model — a host syncs it (below) rather than retyping it.

The data model comes with the package

Do not copy the model into your schema by hand. Use Prisma's multi-file schema folder and sync the package's own partial into it — a byte-for-byte COPY, never a symlink (a symlinked migration is silently skipped by Prisma):

node node_modules/@12-apps/onboarding/scripts/sync-onboarding-schema.mjs prisma/schema

The migration ships in prisma/migrations/, and every statement in it is guarded — so a host that ALREADY has onboarding_states applies it as a no-op, with no prisma migrate resolve dance. See ADOPTING.md.

Wiring

// server: one mount. The host keeps only who is calling, and where data lives.
const onboarding = onboardingRouter({
  db: async () => (await getPrismaClient()) as unknown as OnboardingPrisma,
  featureKeys: ['ai_integration'],
  resolveActor: (c) => resolveActorFor(c), // → { userId, clientId } | null
});
app.route('/api/admin/:tenantSlug', onboarding.router);

// browser: the package's own store, against those endpoints
const store = createOnboardingApiStore({ apiBase, featureKey: 'ai_integration' });
const initial = await fetchOnboardingState({ apiBase, featureKey: 'ai_integration' });

<OnboardingProvider featureKey="ai_integration" store={store} initialState={initial}>
  <GuidedSection steps={steps} title="…" configuredSummary={…} />
</OnboardingProvider>

A host whose persistence is NOT these routes (localStorage, tRPC, server actions) still passes its own OnboardingStore — that seam is unchanged.

版本与发布记录

@12-apps/onboarding 共发布 44 个版本,首次发布于 2026/07/18;过去 12 个月发布了 44 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.7.0latest2026/08/252 个月前
2.6.02026/08/252 个月前
2.5.02026/08/252 个月前
2.4.02026/08/242 个月前
2.3.02026/08/232 个月前
2.2.12026/08/232 个月前

关于 @12-apps/onboarding 的常见问题

@12-apps/onboarding 是什么?

Reusable guided onboarding: React provider + GuidedSection and the API-bound OnboardingStore (.), the host-mounted progress surface (./server: createApiOnboarding — GET/PATCH progress with save/dismiss/reset), a Hono adapter (./hono), and the package-owne

如何安装 @12-apps/onboarding?

在项目目录运行 npm install @12-apps/onboarding,或使用 pnpm add / yarn add / bun add。

@12-apps/onboarding 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@12-apps/onboarding 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@12-apps/onboarding 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@12-apps/onboarding 可以商用吗?

@12-apps/onboarding 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@12-apps/onboarding 的下载量有多少?

根据 npm 官方下载统计,@12-apps/onboarding 在 2026/10/04 – 2026/11/02 这 30 天内被下载 32,604 次,日均约 1,087 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@12-apps/onboarding 还在维护吗?

最新版本 2.7.0 发布于 2026/08/25(2 个月前);至今共发布 44 个版本,其中过去 12 个月发布了 44 个;首次发布于 2026/07/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。