@fierst/c7t 0.0.0-stage → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +62 -2
  4. package/bin/c7t.d.mts +1 -0
  5. package/bin/c7t.mjs +107 -0
  6. package/bin/create.d.mts +9 -0
  7. package/bin/create.mjs +337 -0
  8. package/dist/adapters/bun.d.mts +40 -0
  9. package/dist/adapters/bun.mjs +114 -0
  10. package/dist/adapters/cloudflare.d.mts +29 -0
  11. package/dist/adapters/cloudflare.mjs +28 -0
  12. package/dist/adapters/node.d.mts +31 -0
  13. package/dist/adapters/node.mjs +139 -0
  14. package/dist/adapters/static.d.mts +34 -0
  15. package/dist/adapters/static.mjs +53 -0
  16. package/dist/adapters/vercel.d.mts +40 -0
  17. package/dist/adapters/vercel.mjs +79 -0
  18. package/dist/client.d.mts +78 -0
  19. package/dist/client.mjs +181 -0
  20. package/dist/head-CUiNFY7Q.mjs +142 -0
  21. package/dist/index.d.mts +77 -0
  22. package/dist/index.mjs +25 -0
  23. package/dist/multipart-CwqTb3AQ.mjs +72 -0
  24. package/dist/protocol-B6QOAMGj.d.mts +115 -0
  25. package/dist/protocol-CZANZJ5x.mjs +126 -0
  26. package/dist/router-19ZZ3woS.d.mts +148 -0
  27. package/dist/router-B50LekA_.mjs +680 -0
  28. package/dist/router.d.mts +2 -0
  29. package/dist/router.mjs +1 -0
  30. package/dist/search-params-C03mU47i.mjs +79 -0
  31. package/dist/server.d.mts +146 -0
  32. package/dist/server.mjs +850 -0
  33. package/dist/ssg-DFBgqaob.d.mts +40 -0
  34. package/dist/ssg.d.mts +2 -0
  35. package/dist/ssg.mjs +179 -0
  36. package/dist/vite.d.mts +95 -0
  37. package/dist/vite.mjs +920 -0
  38. package/docs/README.md +26 -0
  39. package/docs/guides/01-getting-started.md +164 -0
  40. package/docs/guides/02-data-fetching-and-mutations.md +258 -0
  41. package/docs/guides/03-streaming-and-workflows.md +198 -0
  42. package/docs/guides/04-routing-layouts-and-state.md +236 -0
  43. package/docs/guides/05-auth-sessions-and-security.md +179 -0
  44. package/docs/guides/06-ssg-and-deployment.md +247 -0
  45. package/docs/guides/07-databases-and-drizzle.md +200 -0
  46. package/docs/reference.md +112 -0
  47. package/llms.txt +1627 -0
  48. package/package.json +122 -4
  49. package/template/gitignore +11 -0
  50. package/template/package.json +22 -0
  51. package/template/src/routes/404.tsx +16 -0
  52. package/template/src/routes/about.tsx +22 -0
  53. package/template/src/routes/index.tsx +41 -0
  54. package/template/src/routes/layout.tsx +14 -0
  55. package/template/src/styles.css +39 -0
  56. package/template/tsconfig.json +18 -0
  57. package/template/vite.config.ts +16 -0
@@ -0,0 +1,200 @@
1
+ # 07. Databases, `defineDb()`, and Drizzle ORM
2
+
3
+ `@fierst/c7t` keeps its core runtime 100% database-agnostic while providing a first-class paved road for SQL databases through two pieces:
4
+
5
+ 1. **`defineDb()` (`@fierst/c7t/server`):** A zero-dependency, lazy database proxy that seamlessly bridges Node/Bun connection pools (`process.env.DATABASE_URL`) and Cloudflare Workers per-request bindings (`req.env.DB` D1 / Hyperdrive) without passing `db` arguments through every function.
6
+ 2. **`c7t create --db=sqlite|postgres|d1`:** Opt-in project scaffolding powered by **[Drizzle ORM](https://orm.drizzle.team)** + **`drizzle-valibot`**, turning a single SQL table definition into your database schema, TypeScript row types, and `server(Schema, fn)` Standard Schema v1 validator!
7
+
8
+ ---
9
+
10
+ ## 1. Scaffold a Project with Drizzle (`--db`)
11
+
12
+ Choose your database target when scaffolding a project (omit `--db` if you don't need a database):
13
+
14
+ ```bash
15
+ # Local SQLite / Turso / LibSQL (zero native C++ compile — works everywhere)
16
+ npx @fierst/c7t my-app --db=sqlite
17
+
18
+ # PostgreSQL / Neon / Supabase
19
+ npx @fierst/c7t my-app --db=postgres
20
+
21
+ # Cloudflare Workers D1 (auto-configures cloudflarePreset() + wrangler.jsonc)
22
+ npx @fierst/c7t my-app --db=d1
23
+ ```
24
+
25
+ Push your initial schema and launch the dev server + visual database studio:
26
+
27
+ ```bash
28
+ cd my-app
29
+ npm install
30
+ npm run db:push # Push src/db/schema.ts directly to your database
31
+ npm run dev # Start Construct at http://localhost:5173
32
+ npm run db:studio # Optional: inspect tables in Drizzle Studio
33
+ ```
34
+
35
+ ---
36
+
37
+ ## 2. How `defineDb()` Solves Singleton Pools & Edge Bindings
38
+
39
+ In traditional frameworks, switching from Node/Bun (where you want **one module-level connection pool** reused across requests) to Cloudflare Workers (where D1 and Hyperdrive bindings are injected **per request** on `env.DB` inside `fetch(req, env)`) forces you to refactor every helper function to accept `(db, ...)` as an argument.
40
+
41
+ `defineDb(factory, options?)` eliminates that split using `c7t`'s `AsyncLocalStorage` request store:
42
+
43
+ - **Lazy Initialization:** Importing `db` at module top-level opens **zero connections** until a query actually runs—keeping build-time route discovery and edge cold starts instantaneous.
44
+ - **Smart `scope: "auto"` Caching (Default):**
45
+ - When running on Node.js, Bun, or Vercel against `process.env`, `defineDb()` initializes your pool once and reuses the singleton across requests.
46
+ - When running on Cloudflare Workers with request bindings (`req.env.DB`), `defineDb()` caches the Drizzle wrapper in a `WeakMap` keyed by `req.env`—isolating bindings cleanly with zero per-query allocation overhead.
47
+ - **Private-Field Safe:** Method accesses bind the underlying client (`Reflect.get` + `.bind()`), so native classes using ES `#private` fields (such as Node's built-in `node:sqlite` `DatabaseSync`) work out of the box.
48
+
49
+ ### Example A: SQLite / LibSQL / Turso (`--db=sqlite`)
50
+
51
+ ```ts
52
+ // src/db/index.ts
53
+ import { createClient } from "@libsql/client";
54
+ import { drizzle } from "drizzle-orm/libsql";
55
+ import { defineDb } from "@fierst/c7t/server";
56
+ import * as schema from "./schema";
57
+
58
+ export const db = defineDb((env) => {
59
+ const client = createClient({
60
+ url: env.DATABASE_URL ?? "file:local.db",
61
+ authToken: env.DATABASE_AUTH_TOKEN,
62
+ });
63
+ return drizzle(client, { schema });
64
+ });
65
+
66
+ export * from "./schema";
67
+ ```
68
+
69
+ ### Example B: Cloudflare Workers D1 (`--db=d1`)
70
+
71
+ ```ts
72
+ // src/db/index.ts
73
+ import { drizzle } from "drizzle-orm/d1";
74
+ import { defineDb } from "@fierst/c7t/server";
75
+ import * as schema from "./schema";
76
+
77
+ export const db = defineDb((env) => {
78
+ if (!env.DB) throw new Error('Missing Cloudflare D1 binding "DB"');
79
+ return drizzle(env.DB, { schema });
80
+ });
81
+
82
+ export * from "./schema";
83
+ ```
84
+
85
+ ---
86
+
87
+ ## 3. Single Source of Truth: SQL Table -> Standard Schema -> `server()`
88
+
89
+ Because `drizzle-valibot` (and `drizzle-zod`) implement **Standard Schema v1**, `createInsertSchema(table)` passes directly into `server(Schema, fn)`—giving you SQL constraints, runtime HTTP `400` validation, TypeScript inference, and `err.fields` form errors from **one** schema definition:
90
+
91
+ ```ts
92
+ // src/db/schema.ts
93
+ import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
94
+ import { createInsertSchema } from "drizzle-valibot";
95
+ import * as v from "valibot";
96
+
97
+ export const projects = sqliteTable("projects", {
98
+ id: integer("id").primaryKey({ autoIncrement: true }),
99
+ name: text("name").notNull(),
100
+ slug: text("slug").notNull().unique(),
101
+ createdAt: integer("created_at", { mode: "timestamp" })
102
+ .notNull()
103
+ .$defaultFn(() => new Date()),
104
+ });
105
+
106
+ export const InsertProjectSchema = createInsertSchema(projects, {
107
+ name: v.pipe(v.string(), v.trim(), v.minLength(2, "Name must be at least 2 characters")),
108
+ slug: v.pipe(v.string(), v.regex(/^[a-z0-9-]+$/, "Use lowercase letters, numbers, and hyphens")),
109
+ });
110
+ ```
111
+
112
+ Use it directly inside a colocated route (Oxc strips `drizzle-orm` and `../db` from the browser bundle automatically):
113
+
114
+ ```tsx
115
+ // src/routes/projects/index.tsx
116
+ import { desc } from "drizzle-orm";
117
+ import { head, server, ValidationError } from "@fierst/c7t";
118
+ import { db, InsertProjectSchema, projects } from "../../db";
119
+
120
+ export const listProjects = server(async () => {
121
+ return db.select().from(projects).orderBy(desc(projects.createdAt));
122
+ });
123
+
124
+ export const createProject = server(InsertProjectSchema, async (input) => {
125
+ const [created] = await db
126
+ .insert(projects)
127
+ .values({ name: input.name, slug: input.slug })
128
+ .returning();
129
+ return created;
130
+ });
131
+
132
+ export default function* ProjectsPage() {
133
+ let rows = yield* listProjects();
134
+ let name = "";
135
+ let slug = "";
136
+ let errors: Record<string, string> = {};
137
+
138
+ head({ title: "Projects" });
139
+
140
+ return () => (
141
+ <main>
142
+ <h1>Projects ({rows.length})</h1>
143
+
144
+ <form
145
+ onSubmit={async (e) => {
146
+ e.preventDefault();
147
+ errors = {};
148
+ try {
149
+ const created = await createProject({ name, slug });
150
+ rows = [created, ...rows];
151
+ name = "";
152
+ slug = "";
153
+ } catch (err) {
154
+ if (err instanceof ValidationError) {
155
+ errors = err.fields;
156
+ return;
157
+ }
158
+ throw err;
159
+ }
160
+ }}
161
+ >
162
+ <input bind:value={name} placeholder="Project name" />
163
+ {errors.name && <span class="error">{errors.name}</span>}
164
+
165
+ <input bind:value={slug} placeholder="project-slug" />
166
+ {errors.slug && <span class="error">{errors.slug}</span>}
167
+
168
+ <button type="submit">Create Project</button>
169
+ </form>
170
+
171
+ <ul>
172
+ {rows.map((p) => (
173
+ <li key={p.id}>
174
+ <a href={`/projects/${p.slug}`}>{p.name}</a>
175
+ </li>
176
+ ))}
177
+ </ul>
178
+ </main>
179
+ );
180
+ }
181
+ ```
182
+
183
+ ---
184
+
185
+ ## 4. Using Built-In `node:sqlite`, `Bun.sql`, or Kysely
186
+
187
+ `defineDb()` is completely ORM-agnostic. For zero-dependency local tools on Node.js 22.5+, you can even wrap Node's built-in `node:sqlite` directly:
188
+
189
+ ```ts
190
+ import { DatabaseSync } from "node:sqlite";
191
+ import { defineDb } from "@fierst/c7t/server";
192
+
193
+ export const sqlite = defineDb((env) => {
194
+ const conn = new DatabaseSync(env.SQLITE_PATH ?? "./app.db");
195
+ conn.exec("PRAGMA journal_mode = WAL;");
196
+ return conn;
197
+ });
198
+ ```
199
+
200
+ Need the raw unwrapped instance for `instanceof` checks or driver plugins? Access **`db.$client`**.
@@ -0,0 +1,112 @@
1
+ # `@fierst/c7t` API Reference
2
+
3
+ `@fierst/c7t` is an ESM-first TypeScript package requiring **Node.js >= 20.19.0** (or Bun / Cloudflare `workerd` with `nodejs_als`) and `@fierst/blokd >= 1.3.0-beta.1`.
4
+
5
+ ---
6
+
7
+ ## 1. Isomorphic Core (`@fierst/c7t`)
8
+
9
+ Safe to import in any `.tsx` or `.ts` module (SSR, SSG, and Browser):
10
+
11
+ | Export | Signature & Behavior |
12
+ | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
13
+ | `server(fn)` / `server(Schema, fn)` | Wrap an `async (...args) => T` function into a dual-protocol `ServerCall<T>` (`yield*` + `await`), or wrap an `async function* (...args)` into an NDJSON streaming generator (`for await`). Optional first argument validates `args[0]` via Standard Schema v1 (Valibot, Zod, ArkType). |
14
+ | `all([...calls])` | Execute a tuple or array of `ServerCall` / `STEP` generators concurrently (`Promise.all` on SSR/client mount, 0-tick replay on revival) and return their typed tuple `[A, B, ...]`. |
15
+ | `head(config)` | `{ title?, description?, canonical?, meta?: HeadMetaTag[] }`. Merges outer-to-inner into `<head>` on SSR and updates `document` head tags in-place on client navigation. |
16
+ | `searchParam(key, defaultValue, opts?)` | Returns a Blokd `Signal<T>` (`string \| number \| boolean`) synced with URL query parameter `key`. Works directly with `bind:value` and `bind:checked`. Options: `{ replace?: boolean }` (default `true`). |
17
+ | `defineEnv({ server, public, runtimeEnv? })` | Validate environment variables via Standard Schema v1 across Cloudflare `req.env`, `process.env`, and `import.meta.env`. Accessing a `server` key in the browser throws immediately. |
18
+ | `redirect(location, status?)` | Construct a `RedirectSignal` (`301 \| 302 \| 303 \| 307 \| 308`, default `302`). Throw inside SSR routes or `server()` handlers (`throw redirect("/login")`). |
19
+ | `notFound(msg?)`, `unauthorized(msg?)`, `forbidden(msg?)`, `httpError(status, msg?, data?)` | Construct an `HttpStatusError` (`404`, `401`, `403`, or custom HTTP status). `throw notFound()` on SSR renders `src/routes/404.tsx` with HTTP `404`. |
20
+ | `ValidationError` | Thrown when Standard Schema validation fails (`status = 400`, `issues`, and lazy `err.fields: Record<string, string>` dot-path map). |
21
+ | `RouteProps<Path>` | `{ params: ExtractRouteParams<Path>, search: URLSearchParams, pathname: string, children?: View }`. Infers `[id]` and `[...slug]` params from template-literal route paths. |
22
+ | `useRoute()`, `navigate(to, opts?)` | Read `{ pathname, search, params }` in any descendant component, or trigger client-side navigation programmatically (`{ replace?, transition? }`). |
23
+ | `buildRoutes(entries)`, `buildApiRoutes(entries)`, `extractSpecialRoutes(entries)`, `Outlet` | Low-level route compilation helpers used by `virtual:c7t/routes` and custom programmatic servers. |
24
+
25
+ ---
26
+
27
+ ## 2. Server Runtime (`@fierst/c7t/server`)
28
+
29
+ Server-only module (importing runtime bindings outside `server(...)` in client code is blocked at build time):
30
+
31
+ | Export | Signature & Behavior |
32
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33
+ | `createServer(options?)` | Returns a `Hono` app configured with `AsyncLocalStorage` request scoping, user `middleware`, `POST /_c7t/rpc/:fnId` (CSRF + validation + NDJSON stream cancellation), file-system API routes, zero-FOUC CSS `<link>` injection, `404.tsx` / `error.tsx`, and streaming SSR (`ssrMode: "stream" \| "string"`). |
34
+ | `req` | Ambient `C7tRequest` proxy (`req.url`, `req.method`, `req.headers`, `req.raw`, `req.env`, `req.signal`, `req.c`, plus augmented `RequestContext` fields). |
35
+ | `cookies` | `{ get(name), set(name, value, options?), delete(name, options?) }`. Throws a build-time guardrail error if accessed while prerendering a static SSG route. |
36
+ | `createSession<T>(config)` | Web-Crypto (`HMAC-SHA256`) signed `httpOnly` cookie session manager: `{ get(), set(data), clear() }`. Supports secret rotation via `secret: [currentKey, oldKey]`. |
37
+ | `defineDb(factory, options?)` | Lazy, ORM-agnostic database proxy (`scope?: "auto" \| "singleton" \| "request"`). Reuses singletons on Node/Bun (`process.env`) and isolates per-request bindings on Cloudflare Workers (`req.env.DB`). Exposes `db.$client` for raw instance access. |
38
+ | `runWithRequestContext(c, fn, signal?)` | Run arbitrary async work inside `c7t`'s Hono `AsyncLocalStorage` context. |
39
+ | `registerServerFn(id, schemaOrFn, maybeFn?)` | Low-level RPC registration helper emitted by `@fierst/c7t/vite`. |
40
+
41
+ ### `CreateServerOptions`
42
+
43
+ - `routes?: readonly RouteModuleEntry[] | readonly CompiledRoute[]` — Defaults to auto-discovered `src/routes/**` when built with `@fierst/c7t/vite`.
44
+ - `middleware?: MiddlewareHandler | readonly MiddlewareHandler[]` — Runs identically on SSR page loads, file-system API routes, and `/_c7t/rpc/*`.
45
+ - `configure?: (app: Hono) => void` — Escape hatch to mount custom Hono routes or sub-apps.
46
+ - `notFoundComponent?: ComponentFn<{ pathname: string }>` — Overrides `src/routes/404.tsx`.
47
+ - `errorComponent?: ComponentFn<{ error: unknown; reset: () => void }>` — Overrides `src/routes/error.tsx`.
48
+ - `styles?: readonly string[]` — Additional stylesheet hrefs injected into `<head>`.
49
+ - `ssrMode?: "stream" | "string"` — Defaults to `"stream"`.
50
+ - `rpcBase?: string` — Defaults to `"/_c7t/rpc"`.
51
+ - `document?: Omit<DocumentOptions, "receipts"> & { clientEntryUrl?: string }` — Customize `lang`, `title`, `head`, `nonce` (CSP), `importmap`, or `revive` (`true | false | "auto"`).
52
+ - `manifest?: RevivalManifest` — Explicit production asset manifest override.
53
+
54
+ ---
55
+
56
+ ## 3. Client Runtime (`@fierst/c7t/client`)
57
+
58
+ | Export | Signature & Behavior |
59
+ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
60
+ | `installC7t(options?)` | Installs the `$ref` State Receipt decoder, Blokd lazy island revival, and persistent nested `<c7t-outlet>` client router. Called automatically by `virtual:c7t/client-entry`. |
61
+ | `configureClient(config)` | Configure `{ rpcBase?, fetch? }` on the client. |
62
+ | `createRpcStub(fnId)` | Low-level dual-protocol RPC stub factory emitted by `@fierst/c7t/vite`. Automatically switches to `multipart/form-data` when arguments contain `File`, `Blob`, or `FormData`. |
63
+ | `createStreamStub(fnId)` | Low-level NDJSON `AsyncGenerator` stub factory with owner auto-refresh and `AbortController` teardown. |
64
+
65
+ ---
66
+
67
+ ## 4. Vite+ Compiler, Build Pipeline, & CLI (`@fierst/c7t/vite` & `c7t`)
68
+
69
+ | Export / Command | Description |
70
+ | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
71
+ | `c7t(options?)` | Default & named Vite+ plugin (`routesDir`, `serverEntry`, `hashIds`, `adapter`, `prerender?: boolean \| "marked" \| "all"`, `csr?: "auto" \| "islands" \| boolean`, `blokd`). |
72
+ | `buildApp(options?)` | Programmatic 3-stage production builder (`{ root?, adapter?, prerender?, logLevel? }`) returning `BuildAppResult`. |
73
+ | `compileC7tModule(code, opts)` | Low-level Oxc AST transform for `*.server.ts` and colocated `server()` / `prerender` stripping. |
74
+ | `c7t <dir> [--db=sqlite\|postgres\|d1]` / `c7t create <dir>` | Scaffold a new `c7t` starter project (with optional Drizzle + `drizzle-valibot` database setup). |
75
+ | `c7t build [--adapter=<t>] [--prerender=all\|marked\|false]` | Run Client -> SSR -> SSG + Adapter build pipeline. |
76
+ | `c7t start [--port=3000]` | Boot `dist/server/start.mjs` in production mode. |
77
+
78
+ ---
79
+
80
+ ## 5. Static Site Generation & Deployment Adapters
81
+
82
+ | Subpath | Exports |
83
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
84
+ | `@fierst/c7t/ssg` | `prerenderApp(options)` (`mode: "marked" \| "all"`, `crawl`, `entries`, `onBrokenLink`), `getSidecarPathname(path)` |
85
+ | `@fierst/c7t/node` | `serveNode(app, opts?)`, `createNodeHandler(app, opts?)`, `nodeAdapter(opts?)` |
86
+ | `@fierst/c7t/cloudflare` | `cloudflareAdapter(app, opts?)`, `cloudflarePreset(opts?)` |
87
+ | `@fierst/c7t/vercel` | `buildVercelOutput(opts?)`, `vercelAdapter(opts?)` (Vercel Build Output API v3) |
88
+ | `@fierst/c7t/bun` | `serveBun(app, opts?)`, `createBunFetchHandler(app, opts?)`, `bunAdapter(opts?)` |
89
+ | `@fierst/c7t/static` | `buildStaticSite(opts)`, `staticAdapter(opts?)` |
90
+
91
+ ---
92
+
93
+ ## 6. Route Module Exports Reference (`src/routes/**`)
94
+
95
+ | Export in Route File | Purpose |
96
+ | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | `export default function* Page(props)` | UI page or layout component (`function`, `function*`, or `async function*`). |
98
+ | `export const prerender = true \| false \| (() => [...])` | Prerender route (or layout subtree) to static HTML + `__c7t.json` sidecar, or pass `false` to opt a route out of global `prerender: true`. |
99
+ | `export const csr = "auto" \| "islands" \| true \| false` | Client JS mode (cascades from `c7t()` config -> `layout.tsx` -> page; defaults to `"auto"`, emitting 0 `<script>` tags when 0 islands render). |
100
+ | `export async function GET(c)` (`POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS`) | Raw Hono HTTP endpoint handler at the route's URL pattern. |
101
+
102
+ ---
103
+
104
+ ## 7. Troubleshooting & Diagnostics
105
+
106
+ | Symptom | Cause & Resolution |
107
+ | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
108
+ | `[c7t] "..." references server-only import(s) (cookies) from "@fierst/c7t/server" in client code` | `cookies` or `req` was referenced in JSX or component setup outside a `server(...)` block. Move the access inside `server(async () => { ... })` and call `yield* fn()`. |
109
+ | `[c7t SSG] Cannot call cookies.get while prerendering static route` | A route marked `prerender = true` (or crawled under `prerender: "all"`) read request cookies/sessions at build time. Remove `prerender` from personalized routes or move user state to a client RPC after interaction. |
110
+ | `[Blokd] Receipt step mismatch` warning in dev console | Conditional logic (`typeof window`, `Math.random()`) changed the order of `yield*` `server()` calls between SSR and client revival. Keep `yield*` calls deterministic across server and client. |
111
+ | Cross-origin `POST /_c7t/rpc/*` returns `403 Forbidden` | `c7t`'s CSRF guard blocks cross-site RPCs when `Origin` mismatches. For third-party webhooks or public CORS APIs, export a file-system `POST(c)` handler (`src/routes/api/webhook.ts`) instead of an internal RPC. |
112
+ | Unexpected server error shows `"Internal Server Error"` in prod | `NODE_ENV="production"` masks unhandled `500` errors on the wire for security. Inspect server logs (`[c7t RPC error]`) or throw `httpError(422, "Safe user-facing message")` when the message is intended for the UI. |