@nifrajs/cli 5.6.0 → 5.7.0
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.
- package/CHANGELOG.md +159 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +4 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +6 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +1 -30
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +35 -12
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +53 -5
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +5 -0
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +18 -6
- package/dist/command-catalog.js.map +1 -1
- package/dist/contracts.d.ts +42 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +288 -9
- package/dist/contracts.js.map +1 -1
- package/dist/doctor.d.ts +6 -4
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +20 -6
- package/dist/doctor.js.map +1 -1
- package/dist/internal/git-ignored.d.ts +12 -0
- package/dist/internal/git-ignored.d.ts.map +1 -0
- package/dist/internal/git-ignored.js +49 -0
- package/dist/internal/git-ignored.js.map +1 -0
- package/dist/internal/source-facts.d.ts +29 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +160 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/load.d.ts +4 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +10 -0
- package/dist/load.js.map +1 -1
- package/dist/local-cli.d.ts +15 -0
- package/dist/local-cli.d.ts.map +1 -0
- package/dist/local-cli.js +74 -0
- package/dist/local-cli.js.map +1 -0
- package/dist/lock-links.d.ts +0 -7
- package/dist/lock-links.d.ts.map +1 -1
- package/dist/lock-links.js +5 -44
- package/dist/lock-links.js.map +1 -1
- package/dist/mcp-delegate.d.ts +13 -5
- package/dist/mcp-delegate.d.ts.map +1 -1
- package/dist/mcp-delegate.js +24 -8
- package/dist/mcp-delegate.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/openapi-types.d.ts.map +1 -1
- package/dist/openapi-types.js +45 -2
- package/dist/openapi-types.js.map +1 -1
- package/dist/recipes/5.7.0.d.ts +12 -0
- package/dist/recipes/5.7.0.d.ts.map +1 -0
- package/dist/recipes/5.7.0.js +70 -0
- package/dist/recipes/5.7.0.js.map +1 -0
- package/dist/recipes/index.d.ts +13 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +2 -0
- package/dist/review.js.map +1 -1
- package/dist/rules/codes.d.ts +2 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +2 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +13 -3
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/legacy.js +1 -1
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/text-slot-boolean.d.ts +8 -0
- package/dist/rules/text-slot-boolean.d.ts.map +1 -0
- package/dist/rules/text-slot-boolean.js +57 -0
- package/dist/rules/text-slot-boolean.js.map +1 -0
- package/dist/rules/undeclared-response.d.ts +9 -0
- package/dist/rules/undeclared-response.d.ts.map +1 -0
- package/dist/rules/undeclared-response.js +93 -0
- package/dist/rules/undeclared-response.js.map +1 -0
- package/dist/upgrade.d.ts +34 -8
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +197 -25
- package/dist/upgrade.js.map +1 -1
- package/dist/version-drift.js +1 -1
- package/dist/version-drift.js.map +1 -1
- package/dist/web-app-options.d.ts +1 -1
- package/dist/web-app-options.d.ts.map +1 -1
- package/dist/web-app-options.js.map +1 -1
- package/docs/examples.json +7 -1
- package/docs/llms-full.txt +441 -105
- package/docs/types.json +164 -43
- package/package.json +11 -11
- package/src/check-diagnostics.ts +4 -0
- package/src/check-scan.ts +1 -29
- package/src/check.ts +32 -10
- package/src/cli.ts +58 -5
- package/src/command-catalog.ts +23 -6
- package/src/contracts.ts +348 -14
- package/src/doctor.ts +28 -12
- package/src/internal/git-ignored.ts +47 -0
- package/src/internal/source-facts.ts +198 -0
- package/src/load.ts +16 -0
- package/src/local-cli.ts +83 -0
- package/src/lock-links.ts +5 -43
- package/src/mcp-delegate.ts +30 -9
- package/src/mcp-http.ts +1 -1
- package/src/openapi-types.ts +43 -2
- package/src/recipes/5.7.0.ts +72 -0
- package/src/recipes/index.ts +16 -0
- package/src/review.ts +2 -0
- package/src/rules/codes.ts +2 -0
- package/src/rules/explanations.ts +13 -3
- package/src/rules/legacy.ts +1 -1
- package/src/rules/text-slot-boolean.ts +56 -0
- package/src/rules/undeclared-response.ts +92 -0
- package/src/upgrade.ts +229 -33
- package/src/version-drift.ts +1 -1
- package/src/web-app-options.ts +1 -0
package/docs/llms-full.txt
CHANGED
|
@@ -12,7 +12,7 @@ nifra is a Bun-native, contract-first, framework-agnostic full-stack TypeScript
|
|
|
12
12
|
- **Secure by default.** Body-size cap, `requestTimeoutMs` + `c.signal`, graceful shutdown, redacting logger, same-origin `redirect()`, constant-time secret comparison, fail-closed middleware.
|
|
13
13
|
- **Money** in integer minor units; **time** parsed to absolute UTC at the boundary.
|
|
14
14
|
- Throwing a `Response` anywhere in the lifecycle is control flow (returned as-is), not an error.
|
|
15
|
-
Optional server components (
|
|
15
|
+
Optional server components (all five adapters): React, Preact, Vue, Svelte and Solid share owner-GET admission, closed input/public-props schemas and private/no-store output. React uses native RSC/Flight. Use *.component.server.ts(x), defineServerComponent, an explicit componentPipeline named config export, native outlets and bindComponentRouter. Await invalidateComponentScope on identity/tenant/permission changes. Component GETs cannot acquire domain write privileges; use validated serverFn/actions for mutations. Native use-server actions are unsupported. Pin the certified compiler tuple documented in /docs/server-components.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -104,8 +104,12 @@ In the `site` template, a route is two files: the page, and a
|
|
|
104
104
|
`.backend.ts` half whose loader calls your backend in-process during SSR and
|
|
105
105
|
whose `actions` handle mutations. Only what the loader's output schema declares
|
|
106
106
|
reaches the browser. Add streaming, `defer()`, optimistic UI, and a keyed query
|
|
107
|
-
cache as you grow
|
|
108
|
-
|
|
107
|
+
cache as you grow, then [live refresh](/docs/live),
|
|
108
|
+
[keep-alive](/docs/keep-alive) pages,
|
|
109
|
+
[server components](/docs/server-components) and
|
|
110
|
+
[partial prerendering](/docs/partial-prerendering) where a page needs them. The
|
|
111
|
+
data model is framework-agnostic, so the renderer stays replaceable. See
|
|
112
|
+
[Project structure](/docs/structure) for where code lives.
|
|
109
113
|
|
|
110
114
|
```ts
|
|
111
115
|
// routes/index.backend.ts - the loader runs on the server (in-process during SSR, no network),
|
|
@@ -143,11 +147,16 @@ export default function Page({ data }: Route.ComponentProps) {
|
|
|
143
147
|
**Cloudflare Workers / Pages** - edge build via `buildServer` +
|
|
144
148
|
`toFetchHandler` (the exact way this self-hosted site is compiled and served).
|
|
145
149
|
|
|
150
|
+
-
|
|
151
|
+
**Vercel Edge, AWS Lambda, or a static host** - `nifra build --target vercel`,
|
|
152
|
+
`@nifrajs/aws-lambda`, or `nifra build --target static` for a
|
|
153
|
+
prerendered site. See [Deployment](/docs/deployment).
|
|
154
|
+
|
|
146
155
|
See the [benchmarks](/benchmarks) for how it performs.
|
|
147
156
|
|
|
148
157
|
## Nifra vs. other frameworks - the honest comparison
|
|
149
158
|
|
|
150
|
-
> How Nifra compares to the full-stack frameworks (Next.js, Nuxt, SvelteKit,
|
|
159
|
+
> How Nifra compares to the full-stack frameworks (Next.js, Nuxt, SvelteKit, React Router, TanStack Start) - and, as a standalone backend, to Hono and Elysia. Five UI frameworks, five runtimes, end-to-end types, partial prerendering, live refresh, and an agentic application layer built around typed capabilities.
|
|
151
160
|
|
|
152
161
|
Honest comparison. Nifra is a **full-stack framework first** - five UI libraries and five runtimes
|
|
153
162
|
from one core, with loaders, actions, streaming, and a typed data layer - and a
|
|
@@ -155,9 +164,9 @@ from one core, with loaders, actions, streaming, and a typed data layer - and a
|
|
|
155
164
|
|
|
156
165
|
### Nifra's lane
|
|
157
166
|
|
|
158
|
-
Every other full-stack framework here is **one UI library
|
|
159
|
-
|
|
160
|
-
in the same project.
|
|
167
|
+
Every other full-stack framework here is **built around one UI library** (TanStack Start
|
|
168
|
+
supports two), and most reach other hosts through adapters. Nifra bets on the other axis: one
|
|
169
|
+
core, five front-ends, many runtimes, with a contract-first typed backend in the same project.
|
|
161
170
|
|
|
162
171
|
Framework
|
|
163
172
|
UI libraries
|
|
@@ -169,9 +178,9 @@ Bun · Node · Deno · Workers · Edge
|
|
|
169
178
|
|
|
170
179
|
Next.js
|
|
171
180
|
React
|
|
172
|
-
Node ·
|
|
181
|
+
Node · Edge runtime · adapters
|
|
173
182
|
|
|
174
|
-
Nuxt
|
|
183
|
+
Nuxt 4
|
|
175
184
|
Vue
|
|
176
185
|
Nitro (many)
|
|
177
186
|
|
|
@@ -179,23 +188,27 @@ SvelteKit
|
|
|
179
188
|
Svelte
|
|
180
189
|
adapters
|
|
181
190
|
|
|
182
|
-
|
|
191
|
+
React Router 7 (Remix)
|
|
183
192
|
React
|
|
184
193
|
adapters
|
|
185
194
|
|
|
186
195
|
TanStack Start
|
|
187
|
-
React
|
|
188
|
-
Nitro
|
|
196
|
+
React · Solid
|
|
197
|
+
Nitro · host plugins
|
|
189
198
|
|
|
190
199
|
### Full-stack parity
|
|
191
200
|
|
|
192
201
|
Across the board, Nifra ships the modern full-stack feature set on all five UI frameworks:
|
|
193
202
|
|
|
194
|
-
-
|
|
203
|
+
-
|
|
204
|
+
File routing (dynamic / catch-all / groups / optional) + nested layouts, typed search
|
|
205
|
+
params, and a route [opened in a modal](/docs/routing#modal-routes).
|
|
195
206
|
|
|
196
207
|
-
|
|
197
|
-
SSR · SSG · ISR, streaming SSR with out-of-order Suspense,
|
|
198
|
-
|
|
208
|
+
SSR · SSG · ISR, streaming SSR with out-of-order Suspense,
|
|
209
|
+
[partial prerendering](/docs/partial-prerendering) (experimental), view
|
|
210
|
+
transitions, and a ~0 KB-client vanilla adapter with
|
|
211
|
+
[islands](/docs/islands) and slot swaps.
|
|
199
212
|
|
|
200
213
|
-
|
|
201
214
|
Loaders + actions + [server functions](/docs/server-functions) (typed
|
|
@@ -203,6 +216,11 @@ Loaders + actions + [server functions](/docs/server-functions) (typed
|
|
|
203
216
|
forms; `defer()` / `<Await>` streaming data; query cache, optimistic
|
|
204
217
|
UI, concurrent fetchers, revalidation.
|
|
205
218
|
|
|
219
|
+
-
|
|
220
|
+
[Live refresh](/docs/live) (a publish reloads only the loaders that read the
|
|
221
|
+
changed keys) and [keep-alive](/docs/keep-alive) pages (back and forward bring
|
|
222
|
+
the same page back, state and scroll included).
|
|
223
|
+
|
|
206
224
|
- Head/meta, hover/focus prefetch, scroll restoration.
|
|
207
225
|
|
|
208
226
|
-
|
|
@@ -222,9 +240,50 @@ mutation API across the supported UI libraries.
|
|
|
222
240
|
|
|
223
241
|
The optional [server-components pipeline](/docs/server-components) adds
|
|
224
242
|
server-only views and state-preserving refresh. React uses native RSC/Flight; Vue, Svelte,
|
|
225
|
-
Solid and Preact use their native islands in validated server-rendered ranges.
|
|
226
|
-
|
|
227
|
-
|
|
243
|
+
Solid and Preact use their native islands in validated server-rendered ranges. All five
|
|
244
|
+
adapters pass the same certification, and a partially prerendered page can show a server
|
|
245
|
+
component in a hole. Server functions remain the mutation API; native React
|
|
246
|
+
`"use server"` actions are unsupported.
|
|
247
|
+
|
|
248
|
+
### Caching and fresh data
|
|
249
|
+
|
|
250
|
+
[SSG and ISR](/docs/rendering) cover pages that change rarely. Three more tools
|
|
251
|
+
cover the pages that do not:
|
|
252
|
+
|
|
253
|
+
-
|
|
254
|
+
**
|
|
255
|
+
[Partial prerendering](/docs/partial-prerendering)
|
|
256
|
+
**
|
|
257
|
+
(experimental, all five adapters). The part of a page that is the same for every visitor is
|
|
258
|
+
built once, cached and sent at once; each per-visitor hole streams into it as its own loader
|
|
259
|
+
settles. The build refuses a shell whose code reaches a module that reads the visitor, and
|
|
260
|
+
`checkShellCanaries` looks for visitor data in a served shell. A shared hole, such
|
|
261
|
+
as a price, is cached on its own schedule and tags. Next.js offers the same model for React
|
|
262
|
+
as partial prerendering under Cache Components.
|
|
263
|
+
|
|
264
|
+
-
|
|
265
|
+
**
|
|
266
|
+
[Live refresh](/docs/live)
|
|
267
|
+
**
|
|
268
|
+
. A loader names the keys its data read with `live(...keys)`; a
|
|
269
|
+
`publish`, or an action's `revalidate(paths, data, { keys })`,
|
|
270
|
+
reloads only those loaders on every open tab that read them, through the hooks, middleware,
|
|
271
|
+
gates and loaders a navigation runs. One WebSocket per tab carries opaque change tags, never
|
|
272
|
+
data. Query hooks can refetch on the same keys. A Redis Streams bus spans processes, and on
|
|
273
|
+
Workers a hibernating Durable Object holds the sockets.
|
|
274
|
+
|
|
275
|
+
-
|
|
276
|
+
**Tag purges in one order.** An action's
|
|
277
|
+
`revalidate(paths, data, { tags, keys })` clears data caches, then the
|
|
278
|
+
page store, then live pages, then the CDN, before it answers, so the visitor who wrote reads
|
|
279
|
+
the write. A page store shared between processes is signed.
|
|
280
|
+
|
|
281
|
+
-
|
|
282
|
+
**
|
|
283
|
+
[Keep-alive](/docs/keep-alive)
|
|
284
|
+
**
|
|
285
|
+
(all five adapters). `export const keepAlive = true` keeps a page mounted after
|
|
286
|
+
the visitor leaves it; back and forward bring it back with its state, scroll and focus.
|
|
228
287
|
|
|
229
288
|
### Also a standalone backend (vs. Hono & Elysia)
|
|
230
289
|
|
|
@@ -262,10 +321,12 @@ emitting a real 3.1 doc with field-level request/response schemas (+ Scalar UI).
|
|
|
262
321
|
**Run it yourself:** `bun run bench:realworld` and
|
|
263
322
|
`bun run bench:http:compare`.
|
|
264
323
|
|
|
265
|
-
### The AI-agent toolchain
|
|
324
|
+
### The AI-agent toolchain
|
|
266
325
|
|
|
267
|
-
|
|
268
|
-
|
|
326
|
+
Agent tooling is no longer rare: Next.js 16 serves a dev-server MCP endpoint, and Svelte
|
|
327
|
+
publishes an MCP server for its docs. Nifra covers both sides of the agent loop: agents that
|
|
328
|
+
edit your codebase and agents that are part of the product. Every surface is anchored to the
|
|
329
|
+
same typed capability boundary:
|
|
269
330
|
|
|
270
331
|
-
|
|
271
332
|
`nifra mcp` - an MCP server exposing `nifra_context` (the project's typed
|
|
@@ -314,21 +375,18 @@ your route contracts, so the compiler catches any frontend/backend drift.
|
|
|
314
375
|
|
|
315
376
|
-
|
|
316
377
|
**The full modern toolkit on your UI of choice** - loaders, actions, streaming SSR with
|
|
317
|
-
out-of-order Suspense, SSG/ISR,
|
|
378
|
+
out-of-order Suspense, SSG/ISR, partial prerendering, live refresh, keep-alive, server
|
|
379
|
+
components, islands, query cache, progressive-enhancement forms.
|
|
318
380
|
|
|
319
381
|
-
|
|
320
|
-
**A framework AI agents edit accurately** - the `nifra mcp` toolchain
|
|
321
|
-
version-checked examples,
|
|
382
|
+
**A framework AI agents edit accurately** - the `nifra mcp` toolchain,
|
|
383
|
+
version-checked examples, and gates that name the fix when a change drifts from the
|
|
384
|
+
contract.
|
|
322
385
|
|
|
323
386
|
-
|
|
324
387
|
**To start lean and grow** - begin as a typed API, graduate to full-stack on the same core,
|
|
325
388
|
no rewrite.
|
|
326
389
|
|
|
327
|
-
Nifra provides streaming SSR, islands and typed
|
|
328
|
-
[server functions](/docs/server-functions). The optional
|
|
329
|
-
[server-components pipeline](/docs/server-components) adds native React
|
|
330
|
-
RSC/Flight and corresponding Vue, Svelte and Solid views under a shared execution contract.
|
|
331
|
-
|
|
332
390
|
## Nifra - Routing
|
|
333
391
|
|
|
334
392
|
> File-based routing in Nifra: conventions, params, nested layouts.
|
|
@@ -384,7 +442,9 @@ its own `notFound()` shows the root page rather than the area's. A nested
|
|
|
384
442
|
data for it; a navigation that lands on one loads the URL as a document. Two route groups
|
|
385
443
|
with a `_404` at one URL prefix are a boot error unless a directory containing
|
|
386
444
|
both has one too. `gone()`, `statusPage()` and the
|
|
387
|
-
`_410.tsx`-style pages stay at the root, as does the 404 of a static export.
|
|
445
|
+
`_410.tsx`-style pages stay at the root, as does the 404 of a static export. A
|
|
446
|
+
helper the browser also loads imports these three from `@nifrajs/web/client`
|
|
447
|
+
rather than the root, whose server half Vite's dev server would otherwise send it.
|
|
388
448
|
|
|
389
449
|
-
|
|
390
450
|
A root status page (`_404.tsx`, `_503.tsx`, ...) or an
|
|
@@ -1256,6 +1316,23 @@ The client's `Result` carries the body, not the response headers. A value the
|
|
|
1256
1316
|
caller acts on, such as how long to wait, belongs in the declared body; set the matching
|
|
1257
1317
|
header too when proxies or plain HTTP clients read it.
|
|
1258
1318
|
|
|
1319
|
+
### Query, header and cookie values are text
|
|
1320
|
+
|
|
1321
|
+
A query string, header values and a `Cookie` header always arrive as text. A
|
|
1322
|
+
`t.object`, `t.query`, `t.headers` or `t.cookies`
|
|
1323
|
+
schema in one of those slots converts the text to the types it declares:
|
|
1324
|
+
`?archived=true` and `?archived=1` are `true`,
|
|
1325
|
+
`?page=2` is `2`, and text that is neither, such as
|
|
1326
|
+
`?archived=yes`, is a `422`. A list is read from repeated keys (
|
|
1327
|
+
`?tag=a&tag=b`), and a comma stays inside its value. A JSON body is already
|
|
1328
|
+
typed, so a `body` schema converts nothing.
|
|
1329
|
+
|
|
1330
|
+
Another Standard Schema gets the text as it came and converts what it says it does. With
|
|
1331
|
+
zod, `z.coerce.boolean()` is `Boolean(value)`, so `"false"`
|
|
1332
|
+
and `"0"` are both `true`. Use `z.stringbool()`, which reads
|
|
1333
|
+
`false`, `0`, `no` and `off` as false and refuses
|
|
1334
|
+
other text; `nifra check` reports the first as NF-C055.
|
|
1335
|
+
|
|
1259
1336
|
### Typed request cookies (schema.cookies)
|
|
1260
1337
|
|
|
1261
1338
|
`c.cookies` is the request's `Cookie` header as a name-to-value record,
|
|
@@ -1296,8 +1373,8 @@ or malformed header is a `422` (`onValidationError` receives the kind
|
|
|
1296
1373
|
`"headers"`), and `c.headers` becomes the schema's typed output.
|
|
1297
1374
|
Every client sends headers no route declares - `host`, `user-agent`,
|
|
1298
1375
|
`accept` - so a closed `t.object` validates only the names it declares,
|
|
1299
|
-
each read case-insensitively, which is also how the OpenAPI document
|
|
1300
|
-
`in: header` parameter per declared name.
|
|
1376
|
+
each read case-insensitively and converted from text, which is also how the OpenAPI document
|
|
1377
|
+
lists them: one `in: header` parameter per declared name.
|
|
1301
1378
|
|
|
1302
1379
|
```ts
|
|
1303
1380
|
import { server } from "@nifrajs/core/server"
|
|
@@ -1538,7 +1615,9 @@ leaves the server. Declare a timestamp as `t.date()` and the page gets a
|
|
|
1538
1615
|
field that is any JSON value, passed through whole - a tool-call payload or a settings blob
|
|
1539
1616
|
the page does not pick apart. A loader without a schema is flagged by
|
|
1540
1617
|
`nifra check`. See
|
|
1541
|
-
[Project structure](/docs/structure) for the route pair.
|
|
1618
|
+
[Project structure](/docs/structure) for the route pair. A loader that names the
|
|
1619
|
+
data it read with `live(...keys)` reloads on its own when that data changes - see
|
|
1620
|
+
[Live refresh](/docs/live).
|
|
1542
1621
|
|
|
1543
1622
|
```ts
|
|
1544
1623
|
// routes/users/[id].backend.ts - a loader runs on the server: in-process during SSR (no network
|
|
@@ -1609,8 +1688,8 @@ loader **revalidates** (no full reload); with JS disabled the native form POST r
|
|
|
1609
1688
|
- progressive enhancement, same code. What the action returns reaches the page as
|
|
1610
1689
|
`actionData`, bounded by `actionOutput`.
|
|
1611
1690
|
|
|
1612
|
-
A reload of the page on screen (an action's revalidation, `invalidate()`, a
|
|
1613
|
-
refresh, a fetcher loading its path again) keeps every part of `data` and the
|
|
1691
|
+
A reload of the page on screen (an action's revalidation, `invalidate()`, a
|
|
1692
|
+
[live refresh](/docs/live), a fetcher loading its path again) keeps every part of `data` and the
|
|
1614
1693
|
layouts' data that it did not change as the same object, with one bound: an array none of
|
|
1615
1694
|
whose first 32 elements is unchanged is replaced whole, so a reload that changed every row
|
|
1616
1695
|
stops comparing early. A row kept this way keeps its DOM and component state: a Solid
|
|
@@ -2045,8 +2124,10 @@ export default function Product({ data }: Route.ComponentProps) {
|
|
|
2045
2124
|
}
|
|
2046
2125
|
```
|
|
2047
2126
|
|
|
2048
|
-
This is request-time progressive SSR
|
|
2049
|
-
|
|
2127
|
+
This is request-time progressive SSR: the whole page, shell included, renders for each
|
|
2128
|
+
request, and deferred values remain request-scoped. To serve the part that is the same for
|
|
2129
|
+
every visitor from a cache and stream only the per-visitor parts, use
|
|
2130
|
+
[partial prerendering](/docs/partial-prerendering) (experimental).
|
|
2050
2131
|
|
|
2051
2132
|
### SSG - prerender at build
|
|
2052
2133
|
|
|
@@ -2121,6 +2202,11 @@ draft-mode visitor renders on demand. So does a page whose build-time render set
|
|
|
2121
2202
|
`no-store`, or varied on a request header other than `Accept-Encoding`
|
|
2122
2203
|
and nifra's own data and slot-swap headers, and every page of an app with a `nonce`. The Vite pipeline and the edge targets render every page on demand.
|
|
2123
2204
|
|
|
2205
|
+
A site with no server at all builds with `nifra build --target static`: it writes
|
|
2206
|
+
the prerendered pages, the client bundle and the `public/` files, for any static
|
|
2207
|
+
host, and fails when no route opts in. A route that is not prerendered has nothing to answer
|
|
2208
|
+
it there.
|
|
2209
|
+
|
|
2124
2210
|
### ISR - cache with stale-while-revalidate
|
|
2125
2211
|
|
|
2126
2212
|
When data changes but not on every request, ISR gives static-like speed with background
|
|
@@ -2442,8 +2528,10 @@ a metric instead of its final value - aggregate those with `delta` or
|
|
|
2442
2528
|
|
|
2443
2529
|
Content that's the same for everyone and changes rarely → **SSG**. Content that changes
|
|
2444
2530
|
occasionally and can tolerate seconds-to-minutes of staleness → **ISR**. Per-request or
|
|
2445
|
-
per-user content → plain **SSR** (the default).
|
|
2446
|
-
|
|
2531
|
+
per-user content → plain **SSR** (the default). A page that is mostly shared with a few
|
|
2532
|
+
per-visitor parts → [partial prerendering](/docs/partial-prerendering)
|
|
2533
|
+
(experimental). You can mix them in one app, route by route. A page that must update while it
|
|
2534
|
+
is open, without a reload, adds [live refresh](/docs/live) to any of them.
|
|
2447
2535
|
|
|
2448
2536
|
## Nifra - Hydration & pre-hydration forms
|
|
2449
2537
|
|
|
@@ -2946,7 +3034,13 @@ export default function Page({ data }: Route.ComponentProps) {
|
|
|
2946
3034
|
|
|
2947
3035
|
The same `defer()` works in actions and across client-side soft navigations (an
|
|
2948
3036
|
NDJSON stream settles the deferred values), and it's framework-agnostic - React
|
|
2949
|
-
`<Suspense>` and Solid's streaming both drive it from one core.
|
|
3037
|
+
`<Suspense>` and Solid's streaming both drive it from one core. See
|
|
3038
|
+
[Frameworks](/docs/frameworks) for which adapters stream the boundary in the
|
|
3039
|
+
server HTML.
|
|
3040
|
+
|
|
3041
|
+
[Partial prerendering](/docs/partial-prerendering) (experimental) streams the same
|
|
3042
|
+
way from a cached shell: the part of the page every visitor shares goes out at once from the
|
|
3043
|
+
cache, and each per-visitor hole streams in as its loader settles.
|
|
2950
3044
|
|
|
2951
3045
|
### Server-Sent Events
|
|
2952
3046
|
|
|
@@ -3206,6 +3300,11 @@ progressive-enhancement forms (work with JS off).
|
|
|
3206
3300
|
|
|
3207
3301
|
- Optimistic UI, targeted revalidation, hover-prefetch, and scroll restoration.
|
|
3208
3302
|
|
|
3303
|
+
-
|
|
3304
|
+
[Live refresh](/docs/live), [keep-alive](/docs/keep-alive) pages,
|
|
3305
|
+
[server components](/docs/server-components), and
|
|
3306
|
+
[partial prerendering](/docs/partial-prerendering) (experimental).
|
|
3307
|
+
|
|
3209
3308
|
-
|
|
3210
3309
|
True HMR in dev for all five (`@nifrajs/web/vite`) - see
|
|
3211
3310
|
[Dev & HMR](/docs/dev).
|
|
@@ -3625,7 +3724,7 @@ import { requestId, logger, etag } from "@nifrajs/middleware"
|
|
|
3625
3724
|
|
|
3626
3725
|
const app = server()
|
|
3627
3726
|
.use(requestId()) // reuse/generate x-request-id → c.requestId (typed) + response header
|
|
3628
|
-
.use(logger()) // one structured line/request: { method, path, status, ms }
|
|
3727
|
+
.use(logger()) // one structured line/request: { method, path: route, status, ms }
|
|
3629
3728
|
.use(etag()) // content-hash ETag on GET 200s → 304 on matching If-None-Match
|
|
3630
3729
|
```
|
|
3631
3730
|
|
|
@@ -3635,7 +3734,11 @@ threads it as `c.requestId`, and echoes the header.
|
|
|
3635
3734
|
|
|
3636
3735
|
-
|
|
3637
3736
|
`logger()` - one structured line per request (method, path, status, duration);
|
|
3638
|
-
covers 404s and errors; route it to your own sink via `log`.
|
|
3737
|
+
covers 404s and errors; route it to your own sink via `log`. The path is the
|
|
3738
|
+
matched route template (`/share/:token`), so ids and tokens in a URL stay out of
|
|
3739
|
+
the logs, and the query string is never logged; `rawPath: true` logs the real
|
|
3740
|
+
path. A plugin of your own that labels requests by route reads the same template with
|
|
3741
|
+
`routeTemplateOf(app)(method, path)` from `@nifrajs/core/server`.
|
|
3639
3742
|
|
|
3640
3743
|
-
|
|
3641
3744
|
`etag()` - adds a content-hash `ETag` to `GET` `200`s
|
|
@@ -3707,7 +3810,15 @@ const app = server()
|
|
|
3707
3810
|
### Operations & docs
|
|
3708
3811
|
|
|
3709
3812
|
`healthcheck()` adds liveness (`/health`) and readiness (`/ready`)
|
|
3710
|
-
endpoints - apply it **before** any auth guard so they stay public.
|
|
3813
|
+
endpoints - apply it **before** any auth guard so they stay public. Each check gets a
|
|
3814
|
+
timeout (`timeoutMs`, default 2 s) and an `AbortSignal` that fires at
|
|
3815
|
+
it; the report names every check's status (`pass`, `fail`,
|
|
3816
|
+
`timeout`) and duration. Probes that arrive together share one run, and a result
|
|
3817
|
+
answers later probes for `cacheMs` (default 1 s), so a public `/ready`
|
|
3818
|
+
cannot be used to hammer the database. A check moving between passing and failing is logged.
|
|
3819
|
+
From the moment `stop()` begins, `/ready` answers
|
|
3820
|
+
`503 stopping`; see graceful shutdown in the custom-server guide.
|
|
3821
|
+
`openapi()`
|
|
3711
3822
|
serves an OpenAPI 3.1 document at `/openapi.json`, generated from your routes - add
|
|
3712
3823
|
`ui: true` for a Scalar API-reference page at `/reference`. The page
|
|
3713
3824
|
loads an exact Scalar version from jsDelivr under a Subresource Integrity hash; serve your own
|
|
@@ -3726,8 +3837,15 @@ exported for build-time generation too.
|
|
|
3726
3837
|
import { healthcheck, openapi } from "@nifrajs/middleware"
|
|
3727
3838
|
|
|
3728
3839
|
app
|
|
3729
|
-
// Liveness + readiness. /ready runs each check concurrently
|
|
3730
|
-
|
|
3840
|
+
// Liveness + readiness. /ready runs each check concurrently, each under a timeout whose
|
|
3841
|
+
// signal it can pass on → 200 (required checks pass) or 503; 503 too once stop() begins.
|
|
3842
|
+
.use(healthcheck({
|
|
3843
|
+
checks: {
|
|
3844
|
+
db: (signal) => db.ping({ signal }),
|
|
3845
|
+
// The app still serves without it: a failure reports "degraded" and keeps 200.
|
|
3846
|
+
cache: { check: () => redis.ping(), optional: true, timeoutMs: 500 },
|
|
3847
|
+
},
|
|
3848
|
+
}))
|
|
3731
3849
|
// GET /openapi.json from your routes (paths, methods, params); ui adds a Scalar page at /reference.
|
|
3732
3850
|
.use(openapi({ info: { title: "My API", version: "1.0.0" }, ui: true }))
|
|
3733
3851
|
```
|
|
@@ -3851,6 +3969,39 @@ const app = server().use(
|
|
|
3851
3969
|
)
|
|
3852
3970
|
```
|
|
3853
3971
|
|
|
3972
|
+
A `key`, on either limiter or on one tier, may be async, so a bucket can follow a
|
|
3973
|
+
session whose signed cookie is checked with WebCrypto first. A key that throws or rejects is
|
|
3974
|
+
charged to the client IP, so an unverified cookie never mints a bucket of its own. Leave out
|
|
3975
|
+
the `floor` when an edge or a shell in front of the app already applies a base
|
|
3976
|
+
limit: a path no tier claims is then not charged twice and carries no
|
|
3977
|
+
`RateLimit-*` headers, and the limiter's rate-limit evidence covers only the routes
|
|
3978
|
+
under its tiers.
|
|
3979
|
+
|
|
3980
|
+
```ts
|
|
3981
|
+
import { server } from "@nifrajs/core/server"
|
|
3982
|
+
import { MemoryStore, rateLimitTiers } from "@nifrajs/middleware"
|
|
3983
|
+
|
|
3984
|
+
// Resolves to the session id once the cookie's signature checks out, and rejects otherwise.
|
|
3985
|
+
declare function verifiedSessionId(req: Request): Promise<string>
|
|
3986
|
+
|
|
3987
|
+
// No floor: the edge already limits every request, so a path no tier claims is not charged
|
|
3988
|
+
// again and gets no RateLimit-* headers.
|
|
3989
|
+
const app = server().use(
|
|
3990
|
+
rateLimitTiers({
|
|
3991
|
+
store: new MemoryStore(),
|
|
3992
|
+
tiers: [
|
|
3993
|
+
{
|
|
3994
|
+
prefix: "/api",
|
|
3995
|
+
max: 90,
|
|
3996
|
+
windowMs: 60_000,
|
|
3997
|
+
// A forged or expired cookie rejects, and is charged to the client IP.
|
|
3998
|
+
key: async (req) => `session:${await verifiedSessionId(req)}`,
|
|
3999
|
+
},
|
|
4000
|
+
],
|
|
4001
|
+
}),
|
|
4002
|
+
)
|
|
4003
|
+
```
|
|
4004
|
+
|
|
3854
4005
|
### A shared store in production
|
|
3855
4006
|
|
|
3856
4007
|
`MemoryStore` counts per instance, so it refuses to start under
|
|
@@ -5181,7 +5332,7 @@ handlers and loaders) or guard with `requireAuthUser(request, config)` (returns
|
|
|
5181
5332
|
the user, or throws a 401/redirect). The frontend half is a framework-agnostic client
|
|
5182
5333
|
(`createAuthClient()` - session, sign-in, sign-out) plus
|
|
5183
5334
|
`<AuthSessionProvider>` / `useAuthSession()` in
|
|
5184
|
-
`@nifrajs/
|
|
5335
|
+
`@nifrajs/authjs/react`.
|
|
5185
5336
|
|
|
5186
5337
|
```ts
|
|
5187
5338
|
// doc-check: skip - needs `@auth/core` providers + AUTH_SECRET; install them to run this.
|
|
@@ -5209,7 +5360,7 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|
|
5209
5360
|
// Frontend - any framework via the agnostic client, or React bindings:
|
|
5210
5361
|
// import { createAuthClient } from "@nifrajs/authjs/client"
|
|
5211
5362
|
// await createAuthClient().signIn("github")
|
|
5212
|
-
// import { AuthSessionProvider, useAuthSession } from "@nifrajs/
|
|
5363
|
+
// import { AuthSessionProvider, useAuthSession } from "@nifrajs/authjs/react"
|
|
5213
5364
|
```
|
|
5214
5365
|
|
|
5215
5366
|
Secrets resolve per request - explicit `secret`, then the `AUTH_SECRET`
|
|
@@ -5435,6 +5586,11 @@ bundle. A page that needs the user reads it from its loader data, which
|
|
|
5435
5586
|
`Origin`/`Referer` doesn't match an allowed origin - the recommended
|
|
5436
5587
|
defense for cookie-auth. Pair it with the rate-limit middleware on your login route.
|
|
5437
5588
|
|
|
5589
|
+
A route no browser calls, such as a payment provider's webhook, arrives with no
|
|
5590
|
+
`Origin` at all. List it in `exempt`, written as the route is (
|
|
5591
|
+
`csrf({ exempt: ["/inbound/:vendor"] })`), and verify the provider's
|
|
5592
|
+
signature in its handler. Exempt nothing that acts on a session cookie.
|
|
5593
|
+
|
|
5438
5594
|
### Cookie Security Defaults
|
|
5439
5595
|
|
|
5440
5596
|
Nifra's `c.set.cookie()` applies secure defaults to every cookie:
|
|
@@ -5503,6 +5659,8 @@ loader at a CDN and the runtime stays tiny. Or self-host: the optional
|
|
|
5503
5659
|
mark the LCP image with `priority` to get `eager` +
|
|
5504
5660
|
`fetchpriority="high"`. Extra DOM props (`className`, `style`,
|
|
5505
5661
|
`id`, `data-*`) pass straight through to the `<img>`.
|
|
5662
|
+
Each adapter's `/image` entry takes `@nifrajs/image` as an optional
|
|
5663
|
+
peer, so the app installs it beside the adapter.
|
|
5506
5664
|
|
|
5507
5665
|
```ts
|
|
5508
5666
|
import { Image } from "@nifrajs/web-react/image"
|
|
@@ -6236,7 +6394,8 @@ portable core.
|
|
|
6236
6394
|
|
|
6237
6395
|
- `<I18nProvider>` + `useT()` ship for **all five adapters**
|
|
6238
6396
|
(React, Preact, Vue, Solid, Svelte) - import from `@nifrajs/web-<framework>/i18n`;
|
|
6239
|
-
each is a thin binding over the agnostic `createFormatter`.
|
|
6397
|
+
each is a thin binding over the agnostic `createFormatter`. `@nifrajs/i18n`
|
|
6398
|
+
is an optional peer of every adapter, so the app installs it beside the adapter.
|
|
6240
6399
|
|
|
6241
6400
|
## Nifra - Edge & bindings
|
|
6242
6401
|
|
|
@@ -6825,6 +6984,10 @@ Vercel Edge
|
|
|
6825
6984
|
|
|
6826
6985
|
none (Build Output API v3)
|
|
6827
6986
|
|
|
6987
|
+
`nifra build --target static` also builds a site with no server: the prerendered
|
|
6988
|
+
pages, the client bundle and `public/`, for any static host. See
|
|
6989
|
+
[SSG & ISR](/docs/rendering).
|
|
6990
|
+
|
|
6828
6991
|
The Bun, Node and Deno entries serve the client bundle from disk next to themselves; on
|
|
6829
6992
|
Cloudflare and Vercel the platform serves it.
|
|
6830
6993
|
|
|
@@ -6919,7 +7082,10 @@ spawn one process per core, each binding the same port with
|
|
|
6919
7082
|
`app.listen(PORT, { reusePort: true })`; the kernel load-balances connections
|
|
6920
7083
|
across them (Linux balances ~evenly). A supervisor that spawns + restarts workers is ~20
|
|
6921
7084
|
lines - see `examples/cluster.ts`. Anything shared across workers (rate limits,
|
|
6922
|
-
sessions, pub/sub) needs a shared store, as in any multi-instance deploy.
|
|
7085
|
+
sessions, pub/sub) needs a shared store, as in any multi-instance deploy. So do an ISR page
|
|
7086
|
+
store (signed with one `storeSecret` in every process - see
|
|
7087
|
+
[SSG & ISR](/docs/rendering)) and
|
|
7088
|
+
[live refresh](/docs/live) (one Redis Streams bus for every process).
|
|
6923
7089
|
|
|
6924
7090
|
### Node & Deno
|
|
6925
7091
|
|
|
@@ -7128,7 +7294,10 @@ the default wherever a command edits files.
|
|
|
7128
7294
|
|
|
7129
7295
|
#### Run and build
|
|
7130
7296
|
|
|
7131
|
-
Develop, build a deploy directory, and run it.
|
|
7297
|
+
Develop, build a deploy directory, and run it. Started from a global or linked install,
|
|
7298
|
+
`nifra dev`, `build`, `start` and `check` run
|
|
7299
|
+
through the project's own `@nifrajs/cli`, so the app loads one
|
|
7300
|
+
`@nifrajs/core`; `NIFRA_LOCAL_CLI=0` runs the CLI as invoked.
|
|
7132
7301
|
|
|
7133
7302
|
Command
|
|
7134
7303
|
What it does
|
|
@@ -7213,7 +7382,7 @@ The breaking-change gate. A new required request field or a removed response fie
|
|
|
7213
7382
|
|
|
7214
7383
|
`nifra contracts snapshot | check`
|
|
7215
7384
|
|
|
7216
|
-
Write the deterministic route contract lock, `contracts.lock.json`, or check the current routes against it.
|
|
7385
|
+
Write the deterministic route contract lock, `contracts.lock.json`, or check the current routes against it. The lock records each declared part (body, query, params, headers, cookies, response, sse, each error status) with its top-level fields, so a failing check names the part and the fields that moved.
|
|
7217
7386
|
|
|
7218
7387
|
`nifra assure [--config <file>]`
|
|
7219
7388
|
|
|
@@ -7406,8 +7575,8 @@ starts from unless nothing else, installed or declared, names one.
|
|
|
7406
7575
|
|
|
7407
7576
|
```bash
|
|
7408
7577
|
nifra upgrade --list # the release targets this CLI knows
|
|
7409
|
-
nifra upgrade 5.
|
|
7410
|
-
nifra upgrade 5.
|
|
7578
|
+
nifra upgrade 5.6.0 # dry-run: every planned edit, nothing written
|
|
7579
|
+
nifra upgrade 5.6.0 --write # apply; it verifies with nifra check once the target is installed
|
|
7411
7580
|
bun install # install the new pins
|
|
7412
7581
|
nifra check # verify against them
|
|
7413
7582
|
nifra doctor # afterwards: no "mixed nifra versions" advisory left
|
|
@@ -9218,17 +9387,20 @@ followed, and a group package installed by a link from outside the root is liste
|
|
|
9218
9387
|
### "records dependencies its file: packages no longer declare"
|
|
9219
9388
|
|
|
9220
9389
|
A `file:` dependency's own dependencies are recorded in `bun.lock` when
|
|
9221
|
-
Bun
|
|
9390
|
+
Bun installs it, and Bun 1.4.2 does not read that package's `package.json` again:
|
|
9222
9391
|
after the linked package moves to a new version of a dependency, `bun install`
|
|
9223
9392
|
(even with `--force`) keeps installing the recorded one beside it, so the app can
|
|
9224
|
-
load two copies of the same package.
|
|
9393
|
+
load two copies of the same package. Bun 1.4.4 reads it on every install.
|
|
9394
|
+
`nifra doctor` (and `nifra check`,
|
|
9225
9395
|
as the `NF-D003` warning) compares each recorded entry with the linked
|
|
9226
9396
|
`package.json` and names every dependency that moved.
|
|
9227
9397
|
|
|
9228
|
-
Run `bun update <package>` for each named package
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9398
|
+
Run `bun update <package>` for each named package: it records the linked
|
|
9399
|
+
`package.json` as it is on disk, uncommitted edits included, and keeps every other
|
|
9400
|
+
entry. Do not delete the entries by hand: an install that finds one missing re-resolves every
|
|
9401
|
+
package in the lock to the newest version its range allows, and Bun 1.4.4 also rewrites a
|
|
9402
|
+
`lockfileVersion` 1 lock as 2. `nifra upgrade` lists the entries against
|
|
9403
|
+
the manifests it is about to write and leaves `bun.lock` as it is.
|
|
9232
9404
|
|
|
9233
9405
|
### Still stuck?
|
|
9234
9406
|
|
|
@@ -9336,7 +9508,8 @@ written down: `nifra fix --code NF-C035` adds
|
|
|
9336
9508
|
|
|
9337
9509
|
With both files, `nifra dev` and `nifra build` take
|
|
9338
9510
|
`apiPrefix`, `apiStrip`, `mounts`, `csp`,
|
|
9339
|
-
`nonce`, `serverComponents`, `i18n`, `
|
|
9511
|
+
`nonce`, `serverComponents`, `i18n`, `hostPolicy`,
|
|
9512
|
+
`live`, `keepAlive`, `use` and
|
|
9340
9513
|
`publicEnvPrefix` from `backend/framework.ts` when
|
|
9341
9514
|
`nifra.config.ts` does not set them, so the
|
|
9342
9515
|
server entry and the dev server read one value without a re-export. A hand-written
|
|
@@ -9356,7 +9529,8 @@ mount in front of the page router.
|
|
|
9356
9529
|
|
|
9357
9530
|
An app run by `nifra dev` and `nifra build` sets these options from
|
|
9358
9531
|
`backend/framework.ts`: `apiPrefix`, `apiStrip`, `mounts`,
|
|
9359
|
-
`csp`, `nonce
|
|
9532
|
+
`csp`, `nonce`, `i18n`, `hostPolicy`, `live` and
|
|
9533
|
+
`keepAlive`. The generated server entry imports them from there, so
|
|
9360
9534
|
export them from `framework.ts` (and re-export from `nifra.config.ts` when
|
|
9361
9535
|
both exist). A `mounts` entry hands a path to another app; a single extra URL
|
|
9362
9536
|
outside the prefix, such as a sitemap, is a plain route registered in `use`:
|
|
@@ -9851,10 +10025,13 @@ same fields, always - `params`, `request`, `api`,
|
|
|
9851
10025
|
interface LoaderContext {
|
|
9852
10026
|
params: Record<string, string> // matched route params (:id, *path)
|
|
9853
10027
|
request: Request // the standard Web Request - read headers/body/URL off it
|
|
10028
|
+
req: Request // alias of request, the name a route handler's c.req uses
|
|
9854
10029
|
api: unknown // the in-process backend client createWebApp was given
|
|
9855
10030
|
env: unknown // platform bindings forwarded from c.env (Workers KV/D1/…)
|
|
9856
10031
|
draft: boolean // true only when a valid draft cookie is present (draftSecret set)
|
|
10032
|
+
search: Record<string, unknown> // the query, validated by the route's searchSchema when it has one
|
|
9857
10033
|
set: LoaderResponseControls // response headers + cookies for this page request (see below)
|
|
10034
|
+
live: (...keys: string[]) => void // the keys this data depends on, for live refresh (/docs/live)
|
|
9858
10035
|
}
|
|
9859
10036
|
|
|
9860
10037
|
// api + env are typed per route by the generated Route.LoaderArgs (./+types/<name>); the agnostic
|
|
@@ -10305,10 +10482,10 @@ file that reaches it.
|
|
|
10305
10482
|
|
|
10306
10483
|
### Optional server components
|
|
10307
10484
|
|
|
10308
|
-
The
|
|
10309
|
-
React, Vue, Svelte and Solid. Declare closed input/public-props schemas and authorization
|
|
10485
|
+
The optional [server-components pipeline](/docs/server-components) supports
|
|
10486
|
+
React, Preact, Vue, Svelte and Solid. Declare closed input/public-props schemas and authorization
|
|
10310
10487
|
in `*.component.server.ts(x)`, register owner instances and export a named
|
|
10311
|
-
`componentPipeline` configuration. React uses native RSC/Flight; the other
|
|
10488
|
+
`componentPipeline` configuration. React uses native RSC/Flight; the other four
|
|
10312
10489
|
hydrate native islands in validated server ranges. Refresh repeats owner GET admission;
|
|
10313
10490
|
HTML/data/refresh are private/no-store. Writes use server functions or actions. Bind the
|
|
10314
10491
|
router and await auth-scope invalidation on identity, tenant or permission changes.
|
|
@@ -10888,6 +11065,15 @@ should stop routing to the instance first, as most platforms do before they send
|
|
|
10888
11065
|
Deno, pass
|
|
10889
11066
|
`signals: { drainMs }` to `serve()` instead, as above.
|
|
10890
11067
|
|
|
11068
|
+
When the platform sends `SIGTERM` without taking the instance out of rotation first,
|
|
11069
|
+
add `delayMs`. The stop then runs the app's `onStopping` hooks, keeps
|
|
11070
|
+
serving for `delayMs`, and only then drains. `healthcheck()` answers
|
|
11071
|
+
`503 stopping` on `/ready` from the moment the stop begins, so the
|
|
11072
|
+
delay is the time a load balancer gets to see that and route elsewhere. Register your own
|
|
11073
|
+
`app.onStopping(fn)` to stop a poller or queue consumer at the same point;
|
|
11074
|
+
`app.onStop(fn)` still runs after the drain, on Bun, Node and Deno alike.
|
|
11075
|
+
`delayMs + drainMs` has to fit in the kill grace period.
|
|
11076
|
+
|
|
10891
11077
|
### Letting check and assure read the app
|
|
10892
11078
|
|
|
10893
11079
|
`nifra check`, `assure`, `routes` and the other commands that
|
|
@@ -12006,20 +12192,19 @@ tells the other tabs of the origin to do the same. A sign-out by a native form p
|
|
|
12006
12192
|
session that expires while the visitor is away, is covered the same way: back compares the
|
|
12007
12193
|
epoch before it shows a kept page.
|
|
12008
12194
|
|
|
12009
|
-
The session cookies of `@nifrajs/auth
|
|
12010
|
-
|
|
12195
|
+
The session cookies of `@nifrajs/auth` and Auth.js count under their default
|
|
12196
|
+
names, and Better Auth's under any `cookiePrefix`. Name any other, such as one
|
|
12197
|
+
renamed through Better Auth's `advanced.cookies`, in
|
|
12198
|
+
`identityCookies`. `nifra dev` and `nifra build` read it
|
|
12199
|
+
from `backend/framework.ts`; a server you write passes the same object to
|
|
12200
|
+
`createWebApp({ keepAlive })`:
|
|
12011
12201
|
|
|
12012
12202
|
```ts
|
|
12013
|
-
//
|
|
12014
|
-
const
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
keepAlive: {
|
|
12019
|
-
identityCookies: ["sid"], // your own session cookie
|
|
12020
|
-
ignoreCookies: ["cart"], // HttpOnly, but says nothing about who is signed in
|
|
12021
|
-
},
|
|
12022
|
-
})
|
|
12203
|
+
// backend/framework.ts
|
|
12204
|
+
export const keepAlive = {
|
|
12205
|
+
identityCookies: ["sid"], // your own session cookie
|
|
12206
|
+
ignoreCookies: ["cart"], // HttpOnly, but says nothing about who is signed in
|
|
12207
|
+
}
|
|
12023
12208
|
```
|
|
12024
12209
|
|
|
12025
12210
|
In development, an `HttpOnly` cookie that changes and is in neither list is
|
|
@@ -12100,6 +12285,13 @@ const app = createWebApp({ adapter, manifest, clientEntry: build.entry, live: li
|
|
|
12100
12285
|
await buildClient({ routesDir, outDir, clientModule, live: liveRuntime.clientEntry })
|
|
12101
12286
|
```
|
|
12102
12287
|
|
|
12288
|
+
A server-rendered page carries a seed: the grant for what its loaders declared, bound to no
|
|
12289
|
+
socket yet. Once the tab's socket opens, one live load trades it for that socket's grant and
|
|
12290
|
+
keeps every owner, so no loader runs again; only gates do. A seed is refused after a minute,
|
|
12291
|
+
for another viewer, another page or a renewal, and then the page loads as it would without
|
|
12292
|
+
one. Partially prerendered pages, server-component routes and Workers apps render without a
|
|
12293
|
+
seed.
|
|
12294
|
+
|
|
12103
12295
|
### Declare keys
|
|
12104
12296
|
|
|
12105
12297
|
`live(...keys)` in any loader, page or layout, names what its data reads. A key
|
|
@@ -12179,6 +12371,42 @@ export const liveRuntime = live({
|
|
|
12179
12371
|
})
|
|
12180
12372
|
```
|
|
12181
12373
|
|
|
12374
|
+
Each process reports through `logger` (default: JSON lines on stderr) when the bus
|
|
12375
|
+
stops answering, when it answers again and when events were lost to a trim.
|
|
12376
|
+
`liveRuntime.status()` has the same state to poll - `down`, open
|
|
12377
|
+
`sockets`, running `loads`, applied `events`, the
|
|
12378
|
+
`changed` frames sent as `notified`, and `lagMs` - for a
|
|
12379
|
+
readiness check or metrics. `close()` stops the reader and closes the sockets;
|
|
12380
|
+
call it before closing the bus's connections. Another process can publish to the same stream
|
|
12381
|
+
with `livePublisher` and a bus that has `send` only. Any client with a
|
|
12382
|
+
raw-command call works: with ioredis, `(command, args) => redis.call(command,
|
|
12383
|
+
...args)`.
|
|
12384
|
+
|
|
12385
|
+
```ts
|
|
12386
|
+
// doc-check: skip - app, liveRuntime, send and read are the ones set up above.
|
|
12387
|
+
import { healthcheck } from "@nifrajs/middleware"
|
|
12388
|
+
import { livePublisher } from "@nifrajs/web/live"
|
|
12389
|
+
import { redisLiveBus } from "@nifrajs/web/live-redis"
|
|
12390
|
+
|
|
12391
|
+
app.use(
|
|
12392
|
+
healthcheck({
|
|
12393
|
+
checks: {
|
|
12394
|
+
// Pages poll while the bus is down: report it without leaving rotation.
|
|
12395
|
+
live: { check: () => !liveRuntime.status().down, optional: true },
|
|
12396
|
+
},
|
|
12397
|
+
}),
|
|
12398
|
+
)
|
|
12399
|
+
app.onStop(async () => {
|
|
12400
|
+
await liveRuntime.close() // stop reading first, so closing its connection is no outage
|
|
12401
|
+
read.close()
|
|
12402
|
+
send.close()
|
|
12403
|
+
})
|
|
12404
|
+
|
|
12405
|
+
// A process that only publishes - a worker, another app - needs no reader and no secret.
|
|
12406
|
+
const publish = livePublisher(redisLiveBus({ send: (command, args) => send.send(command, [...args]) }))
|
|
12407
|
+
await publish("org:42")
|
|
12408
|
+
```
|
|
12409
|
+
|
|
12182
12410
|
### Cloudflare Workers
|
|
12183
12411
|
|
|
12184
12412
|
On Workers, one hibernating Durable Object per app owns the log and holds every socket.
|
|
@@ -12242,7 +12470,10 @@ another `grantTtl` plus a minute has passed.
|
|
|
12242
12470
|
|
|
12243
12471
|
-
|
|
12244
12472
|
Grants are sealed with AES-256-GCM and bound to one socket, path, frame and viewer. They
|
|
12245
|
-
expire (`grantTtl`, default 10 minutes, at most an hour); tabs renew them.
|
|
12473
|
+
expire (`grantTtl`, default 10 minutes, at most an hour); tabs renew them. A
|
|
12474
|
+
page's seed is bound to no socket, so no socket accepts it; only a load of its own page, for
|
|
12475
|
+
its own viewer, within a minute of the render, exchanges it. A shared cache that stores the
|
|
12476
|
+
page stores a seed nobody else can use.
|
|
12246
12477
|
|
|
12247
12478
|
-
|
|
12248
12479
|
The load endpoint and the socket check `Origin`; allow other origins with
|
|
@@ -12571,14 +12802,15 @@ If the project has `nifra.assurance.ts`, run `nifra assure --json`.
|
|
|
12571
12802
|
Exercise every redirect path - loader, action, and layout gate - and, if the app proxies,
|
|
12572
12803
|
each deploy adapter it uses.
|
|
12573
12804
|
|
|
12574
|
-
## Nifra 5
|
|
12805
|
+
## Nifra 5 upgrade guide - from 3.x, 4.x or an earlier 5.x
|
|
12575
12806
|
|
|
12576
|
-
> Upgrade a Nifra 3.x or 4.x application to 5.0: the chained upgrade command, the frontend/backend layout move and its follow-ups, drafted output schemas, the backend's HTTP mount, the 5.0 defaults that changed, and the release gates.
|
|
12807
|
+
> Upgrade a Nifra 3.x or 4.x application to 5.0: the chained upgrade command, the frontend/backend layout move and its follow-ups, drafted output schemas, the backend's HTTP mount, the 5.0 defaults that changed, and the release gates. Then move a 5.x app to 5.6.
|
|
12577
12808
|
|
|
12578
12809
|
Nifra 4.0 split every app into a frontend and a backend half, and 5.0 enforces the split and
|
|
12579
12810
|
changes a handful of defaults. The upgrade command pins the packages and moves imports; the
|
|
12580
12811
|
layout migration moves files; this guide covers what each leaves to you and how to tell a
|
|
12581
|
-
finished migration from one that needs a decision.
|
|
12812
|
+
finished migration from one that needs a decision. An app already on 5.x skips to
|
|
12813
|
+
[Moving to 5.6](#5-6).
|
|
12582
12814
|
|
|
12583
12815
|
### 1. Run the executable upgrade
|
|
12584
12816
|
|
|
@@ -12773,6 +13005,47 @@ If the project has `nifra.assurance.ts`, run `nifra assure --json`.
|
|
|
12773
13005
|
Exercise the pages that load or post data, and every browser call to the backend, under
|
|
12774
13006
|
`nifra dev` and against the production build.
|
|
12775
13007
|
|
|
13008
|
+
### Moving to 5.6
|
|
13009
|
+
|
|
13010
|
+
An app already on 5.x moves with `nifra upgrade 5.6.0`, which prints every note
|
|
13011
|
+
below with the rest of the release's. It moves the imports and dependencies itself; the
|
|
13012
|
+
rest needs a hand:
|
|
13013
|
+
|
|
13014
|
+
-
|
|
13015
|
+
`@nifrajs/islets` and `@nifrajs/web/nano` merge into
|
|
13016
|
+
`@nifrajs/web/islands`. An island host is any element with
|
|
13017
|
+
`data-island="id"`, with its props in
|
|
13018
|
+
`data-island-props`; `<nifra-island data-id>` markers are no
|
|
13019
|
+
longer mounted. An islets `island("id", setup)` becomes
|
|
13020
|
+
`bindIsland(setup)` passed to `mountIslands({ id })`, and a
|
|
13021
|
+
nano signal is read by calling it (`count()`). See
|
|
13022
|
+
[Islands](/docs/islands).
|
|
13023
|
+
|
|
13024
|
+
-
|
|
13025
|
+
`withISR` over any store but `MemoryCacheStore` takes a
|
|
13026
|
+
`storeSecret` of at least 32 random characters, the same in every process, and
|
|
13027
|
+
throws at startup without one. Pages stored before the upgrade render once more.
|
|
13028
|
+
|
|
13029
|
+
-
|
|
13030
|
+
The server-component pipeline is certified on Vite 8.3.4: pin `vite` to exactly
|
|
13031
|
+
that version.
|
|
13032
|
+
|
|
13033
|
+
-
|
|
13034
|
+
An `authenticate()` stage, and `bearer()`, `jwt()`,
|
|
13035
|
+
`basicAuth()` and `apiKey()`, gate the mounts registered after them:
|
|
13036
|
+
register a mount that must stay public first. `idempotency()` covers only the
|
|
13037
|
+
routes declared after it.
|
|
13038
|
+
|
|
13039
|
+
-
|
|
13040
|
+
`t.integer()` refuses values past the safe-integer range by default, forms are
|
|
13041
|
+
parsed by one parser on every runtime, and `@nifrajs/web-vanilla`'s
|
|
13042
|
+
`html` escapes each value for the place it lands and throws on a string as a
|
|
13043
|
+
tag name or inside `<script>`.
|
|
13044
|
+
|
|
13045
|
+
-
|
|
13046
|
+
A Svelte page receives `data` as the router published it, not a deep reactive
|
|
13047
|
+
proxy: copy what you edit into the page's own state.
|
|
13048
|
+
|
|
12776
13049
|
## Nifra - Migrating from Express, Hono, Fastify & Elysia
|
|
12777
13050
|
|
|
12778
13051
|
> Move a backend to Nifra: routing, middleware, validation, and body parsing map directly from Express, Hono, Fastify, and Elysia - and you gain a typed client, multi-runtime deploy, and optional SSR.
|
|
@@ -12916,6 +13189,31 @@ Nifra's client router - `Link` + hover/focus prefetch, scroll restoration
|
|
|
12916
13189
|
|
|
12917
13190
|
`export const meta` (or a `meta()` function of the loader data)
|
|
12918
13191
|
|
|
13192
|
+
`revalidatePath` · `revalidateTag`
|
|
13193
|
+
|
|
13194
|
+
an action's `revalidate(paths, data, { tags })`, or
|
|
13195
|
+
`revalidateEndpoint` for a webhook - see
|
|
13196
|
+
[SSG & ISR](/docs/rendering)
|
|
13197
|
+
|
|
13198
|
+
Server Components · `"use client"`
|
|
13199
|
+
|
|
13200
|
+
opt-in [server components](/docs/server-components) on all five adapters
|
|
13201
|
+
|
|
13202
|
+
Partial prerendering (Cache Components)
|
|
13203
|
+
|
|
13204
|
+
a `shellLoader` and holes - see
|
|
13205
|
+
[Partial prerendering](/docs/partial-prerendering) (experimental)
|
|
13206
|
+
|
|
13207
|
+
Intercepting routes (`(.)photo`)
|
|
13208
|
+
|
|
13209
|
+
a boundary with `{ intercept: "/photos/:id" }` - see
|
|
13210
|
+
[Opening a route in a modal](/docs/routing#modal-routes)
|
|
13211
|
+
|
|
13212
|
+
`keepalive` in `definePageMeta`
|
|
13213
|
+
|
|
13214
|
+
`export const keepAlive = true` - see
|
|
13215
|
+
[Keep-alive](/docs/keep-alive)
|
|
13216
|
+
|
|
12919
13217
|
### Data loading (Next.js → Nifra + React)
|
|
12920
13218
|
|
|
12921
13219
|
The biggest change: data fetching becomes a typed `loader` that calls your backend
|
|
@@ -14286,7 +14584,10 @@ Reaches the browser
|
|
|
14286
14584
|
|
|
14287
14585
|
`routes/x.tsx` (`.svelte`, `.vue`, `.mdx`)
|
|
14288
14586
|
|
|
14289
|
-
a page: the component, `meta
|
|
14587
|
+
a page: the component, `meta`,
|
|
14588
|
+
[
|
|
14589
|
+
`keepAlive`
|
|
14590
|
+
](/docs/keep-alive)
|
|
14290
14591
|
|
|
14291
14592
|
yes
|
|
14292
14593
|
|
|
@@ -14294,6 +14595,8 @@ yes
|
|
|
14294
14595
|
|
|
14295
14596
|
that page's `loader`, `action`, `loaderOutput`,
|
|
14296
14597
|
`actionOutput`, `hydrate`, `revalidate`,
|
|
14598
|
+
`shellLoader` and `boundaryLoaders` (a
|
|
14599
|
+
[partially prerendered](/docs/partial-prerendering) page),
|
|
14297
14600
|
`middleware` (in `_layout.backend.ts`)
|
|
14298
14601
|
|
|
14299
14602
|
never
|
|
@@ -15964,7 +16267,8 @@ export const app = server()
|
|
|
15964
16267
|
mount's `authUrl`, `trustProxy` and `basePath` so the session is read where the mount serves it.
|
|
15965
16268
|
- `requireAuthUser(req, config, { redirectTo? })` - returns the user or throws a 401/redirect.
|
|
15966
16269
|
- `@nifrajs/authjs/client` - `createAuthClient()` (session, sign-in, sign-out) for any frontend.
|
|
15967
|
-
- `@nifrajs/
|
|
16270
|
+
- `@nifrajs/authjs/react` - `<AuthSessionProvider>` + `useAuthSession()` over that client. `react`
|
|
16271
|
+
is an optional peer; only this entry imports it.
|
|
15968
16272
|
|
|
15969
16273
|
Auth.js itself does the security-critical work (PKCE, state, token verification); this package
|
|
15970
16274
|
is the nifra-shaped surface over `@auth/core`. See `/docs/auth` (Auth.js section) for the full
|
|
@@ -16787,6 +17091,11 @@ route. Split groups before the compiler reports `TS2589`, rather than weakening
|
|
|
16787
17091
|
- **Bounded reconciliation workers.** `@nifrajs/core/reconciliation-worker` runs effect or saga
|
|
16788
17092
|
scans under an atomic lease with durable cursor checkpoints, a finite page budget, bounded handler
|
|
16789
17093
|
concurrency, filters, cancellation, and token-only metrics. A worker invocation always terminates.
|
|
17094
|
+
- **`bigint` in plain JSON.** A JSON answer writes a `bigint` as its decimal string
|
|
17095
|
+
(`{ "id": "9007199254740993" }`) instead of failing with a 500, and the typed client reads a
|
|
17096
|
+
`string`. A `Uint8Array` is base64 only where the response schema declares `t.bytes()` from
|
|
17097
|
+
`@nifrajs/schema`; elsewhere it is the `{ "0": 1, ... }` object `JSON.stringify` writes, and a
|
|
17098
|
+
Node `Buffer` is the `{ "type": "Buffer", "data": [...] }` its `toJSON` writes.
|
|
16790
17099
|
- **Rich wire values (opt in).** `@nifrajs/core/wire` round-trips dates, bigints, maps, sets, binary,
|
|
16791
17100
|
shared references, and cycles through JSON transports. Decoding validates every reachable shape,
|
|
16792
17101
|
preserves owned `__proto__` keys without prototype mutation, and enforces configurable node, depth,
|
|
@@ -18592,6 +18901,10 @@ const openapi = toOpenAPI(app) // OpenAPI 3.1
|
|
|
18592
18901
|
…) that become JSON Schema constraints. Validators are compiled (fast).
|
|
18593
18902
|
- **Validating string formats** - `email`/`uuid`/`date-time`/`date`/`time`/`uri`/`ipv4`
|
|
18594
18903
|
validate *and* annotate; register more with `registerFormat`.
|
|
18904
|
+
- **Bytes in a response** - `t.bytes()` declares a field the handler fills with a `Uint8Array` (or a
|
|
18905
|
+
`Buffer`). The route writes it as a base64 string, the typed client reads a `string`, and the
|
|
18906
|
+
document says `{ type: "string", contentEncoding: "base64" }`. Response-only for now: a request or
|
|
18907
|
+
`sse` schema with it is refused at registration.
|
|
18595
18908
|
- **`toOpenAPI`** - richest from a contract (it carries `response` schemas + op names →
|
|
18596
18909
|
`operationId`s); also works on a live app. A Standard Schema that also implements Standard JSON
|
|
18597
18910
|
Schema (zod 4 does) is described like `t`; one that exposes no JSON Schema is emitted without a
|
|
@@ -18632,6 +18945,9 @@ schema whose `validate` does more than check its `jsonSchema`, custom registry k
|
|
|
18632
18945
|
runtime-only metadata, and known TypeBox compiler escape hazards. Use the ordinary `t` adapter for
|
|
18633
18946
|
these shapes. This opt-in build step leaves the existing validation API and runtime behavior intact.
|
|
18634
18947
|
|
|
18948
|
+
A compiled schema in a route's `query`, `headers` or `cookies` slot reads the text there the way the
|
|
18949
|
+
schema it was compiled from does: `?archived=true` is `true` for both.
|
|
18950
|
+
|
|
18635
18951
|
### Forms and files - `@nifrajs/schema/form`
|
|
18636
18952
|
|
|
18637
18953
|
The `t` exported from `@nifrajs/schema/form` is the same builder plus `t.file` and `t.form`. A
|
|
@@ -18709,20 +19025,30 @@ It emits `paths`, `parameters` (path + object query), `requestBody`, and `respon
|
|
|
18709
19025
|
- **`$ref` reuse** - a schema with a `$id` (`t.object({…}, { $id: "User" })`) is hoisted into
|
|
18710
19026
|
`components.schemas` once and referenced by `$ref` everywhere it's used. A Standard JSON Schema's
|
|
18711
19027
|
`$defs` are hoisted the same way, so its refs resolve inside the document.
|
|
18712
|
-
- **Framework errors** - the responses the server answers
|
|
18713
|
-
|
|
18714
|
-
|
|
18715
|
-
|
|
19028
|
+
- **Framework errors** - the responses the server answers itself, as the shared `NifraError`
|
|
19029
|
+
(`{ ok: false, error }`) and `NifraValidationError` (`{ ok: false, error: "validation", issues }`)
|
|
19030
|
+
components: `400`, `413` and `415` on a route with a body, `422` on any route with a request schema
|
|
19031
|
+
(left out when an `onValidationError` hook writes that body), `404` on a path whose parameter has a
|
|
19032
|
+
pattern, `429` with a `Retry-After` header where `rateLimit()` covers the route, and `500` on every
|
|
19033
|
+
route. A declared response wins, so an app whose `onError` or `notFound()` writes another body
|
|
19034
|
+
declares it in `errors`.
|
|
19035
|
+
- **Query, header and cookie values** - a list is read from repeated keys and declared as
|
|
19036
|
+
`style: form, explode: true` (`?tag=a,b` is the one value `"a,b"`). A boolean read from that text
|
|
19037
|
+
(by `t.query`, `t.headers`, `t.cookies`, or a `t.object` in one of those slots) also accepts
|
|
19038
|
+
`1`/`0` and either case, listed on the parameter as `x-nifra-boolean-literals`; another Standard
|
|
19039
|
+
Schema lists none.
|
|
18716
19040
|
- **Tagged unions** - a union whose members all pin one required property to distinct values is
|
|
18717
19041
|
emitted as a `oneOf`. When every member is a component (a `$id`) it also gets a `discriminator`
|
|
18718
19042
|
with a `mapping`, so a client generator can build a tagged union; OpenAPI discriminators never
|
|
18719
19043
|
consider inline members.
|
|
18720
19044
|
- Per-operation **`summary`**, **`description`**, **`tags`**, **`deprecated`** - declared on the contract op.
|
|
18721
19045
|
|
|
18722
|
-
A **contract** is richest (its ops carry all of the above)
|
|
18723
|
-
|
|
18724
|
-
`
|
|
18725
|
-
|
|
19046
|
+
A **contract** is richest (its ops carry all of the above). In **app** mode a route's `response` and
|
|
19047
|
+
`errors` schemas are emitted; a route without a `response` is a generic `200` with no schema, which
|
|
19048
|
+
`nifra check` reports (NF-C054) in a project that builds its document this way. Declare one, build the
|
|
19049
|
+
document with `nifra openapi` (it reads each handler's return type), or pass `options.operations`
|
|
19050
|
+
(keyed by `"METHOD /path"`). Routes using a schema that exposes no JSON Schema are still emitted
|
|
19051
|
+
without body/response detail.
|
|
18726
19052
|
|
|
18727
19053
|
`@nifrajs/core` is a peer dependency. ESM-only. MIT.
|
|
18728
19054
|
|
|
@@ -19201,21 +19527,31 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
19201
19527
|
|
|
19202
19528
|
## @nifrajs/web
|
|
19203
19529
|
|
|
19204
|
-
Optional server components are implemented for React, Vue, Svelte and Solid in the post-4.0
|
|
19205
|
-
feature branch. React uses native RSC/Flight; the other adapters use native islands in validated
|
|
19206
|
-
server ranges. Definitions require closed input/public-props schemas and authorization. Refresh
|
|
19207
|
-
executes the actual owner GET, preserving admission, read capabilities, budgets and cancellation;
|
|
19208
|
-
output is private/no-store. Mutate through validated server functions or actions.
|
|
19209
|
-
|
|
19210
|
-
Use the `/server-components`, `/server-components/client`, `/server-components/islands` and
|
|
19211
|
-
`/server-components/build` exports with an explicit `componentPipeline` named config export.
|
|
19212
|
-
See [the server-components guide](https://nifra.dev/docs/server-components) and the four runnable
|
|
19213
|
-
repository examples for complete entries, native outlets, exact compiler pins and rollback.
|
|
19214
|
-
|
|
19215
19530
|
Framework-agnostic SSR core for nifra - the render seam + HTML document orchestration.
|
|
19216
19531
|
|
|
19217
19532
|
Part of the **[nifra](https://nifra.dev)** full-stack TypeScript framework - one core, five UI libraries, every runtime. Scaffold a new app with `bun create nifra`.
|
|
19218
19533
|
|
|
19534
|
+
One package, the same on React, Preact, Vue, Solid and Svelte (pick the renderer with a
|
|
19535
|
+
`@nifrajs/web-*` adapter):
|
|
19536
|
+
|
|
19537
|
+
- File routing, nested layouts, typed loaders and actions, progressive-enhancement forms, and the
|
|
19538
|
+
client router with prefetch and scroll restoration - [routing](https://nifra.dev/docs/routing),
|
|
19539
|
+
[loaders & actions](https://nifra.dev/docs/data).
|
|
19540
|
+
- Streaming SSR with `defer()`, SSG, and ISR with tag purges - [rendering](https://nifra.dev/docs/rendering).
|
|
19541
|
+
- [Live refresh](https://nifra.dev/docs/live) (`@nifrajs/web/live`, `/live-client`, `/live-redis`):
|
|
19542
|
+
loaders declare keys, a publish reloads only what read them.
|
|
19543
|
+
- [Partial prerendering](https://nifra.dev/docs/partial-prerendering) (`@nifrajs/web/ppr`,
|
|
19544
|
+
experimental): a cached shell, with per-visitor holes streamed in.
|
|
19545
|
+
- [Keep-alive](https://nifra.dev/docs/keep-alive) pages, a query cache, optimistic fetchers, and
|
|
19546
|
+
[islands](https://nifra.dev/docs/islands) (`@nifrajs/web/islands`) for pages with no framework runtime.
|
|
19547
|
+
- Optional [server components](https://nifra.dev/docs/server-components) on all five adapters:
|
|
19548
|
+
React uses native RSC/Flight, the others their own islands in validated server-rendered ranges.
|
|
19549
|
+
Definitions take closed input and public-props schemas and authorization; a refresh runs the
|
|
19550
|
+
owner page's GET with its admission, capabilities, budgets and cancellation. Use the
|
|
19551
|
+
`/server-components`, `/server-components/client`, `/server-components/islands` and
|
|
19552
|
+
`/server-components/build` exports with a `componentPipeline` config export; the repository has a
|
|
19553
|
+
runnable example per adapter.
|
|
19554
|
+
|
|
19219
19555
|
## Guarding pages
|
|
19220
19556
|
|
|
19221
19557
|
A `_layout.backend.ts` loader is data, not a guard: a client navigation can skip it while the browser
|
|
@@ -19748,7 +20084,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
19748
20084
|
|
|
19749
20085
|
## @nifrajs/core
|
|
19750
20086
|
|
|
19751
|
-
`AdmissionController`, `AdmissionDecision`, `AnyServer`, `AuthHeaders`, `AuthMaybePromise`, `AuthenticationFailure`, `AuthenticationFailureReason`, `AuthenticationInput`, `AuthenticationResult`, `AuthenticationStage`, `AuthenticationSuccess`, `Context`, `ContextPlugin`, `CookieOptions`, `CookieSecret`, `DeclaredMountRoute`, `DefinePluginResult`, `DurableObjectNamespaceLike`, `ExecutionContext`, `FRAMEWORK_NAME`, `FetchApp`, `FrameworkError`, `FrameworkName`, `Handler`, `IdentityPlugin`, `InferInput`, `InferOutput`, `JoinRoutePath`, `LambdaEvent`, `LambdaHandler`, `LambdaResponse`, `LambdaV1Event`, `LambdaV2Event`, `ListenTlsOptions`, `LogFields`, `Logger`, `METHODS`, `McpPromptDescriptor`, `McpResourceDescriptor`, `Method`, `Middleware`, `MountFetchOptions`, `MountOptions`, `MountableApp`, `NetlifyEvent`, `NetlifyHandler`, `NifraFeatureVersion`, `NifraPlugin`, `NifraWebSocket`, `NodeRequestContext`, `NodeRequestHook`, `NodeResponseBodyHook`, `NodeResponseContext`, `NodeResponseHook`, `NodeServeOutcome`, `OnRequestResult`, `OpaqueMountDeclaration`, `Params`, `PlainRender`, `Platform`, `PlatformResponse`, `PluginTypeCollapsed`, `PrefixRegistry`, `Prettify`, `PromptArgument`, `PromptMessage`, `ROUTE_PATTERN_OVERLAP_MAX_STATES`, `RedactOptions`, `Registry`, `RequestPath`, `ResponseBodyHook`, `ResponseBodyReplacement`, `ResponseControls`, `ResponseFinalization`, `ResponseHeadersHook`, `ResponseHeadersView`, `ResponseMapFor`, `ResponseResult`, `RouteConfigError`, `RouteConfigErrorCode`, `RouteDescriptor`, `RouteInfo`, `RouteInfoFor`, `RouteMethod`, `RoutePatternOverlapLimitError`, `RouteSchema`, `Router`, `RouterMatch`, `RunningServer`, `SSEContext`, `SSEInit`, `SSEMessage`, `SSEStream`, `ScheduledController`, `ScheduledHandler`, `Server`, `ServerOptions`, `StandardIssue`, `StandardResult`, `StandardSchemaV1`, `StandardTypes`, `StandardWebSocket`, `StatusResponse`, `ToolAnnotations`, `TypedSSEStream`, `UrlParts`, `VERSION`, `ValidationOutcome`, `VercelHandler`, `Version`, `WebSocketContext`, `WebSocketData`, `WebSocketHandler`, `WebSocketUpgradeOutcome`, `authenticated`, `beforeHandler`, `commonSecretPatterns`, `cookieNamePrefix`, `defineContextPlugin`, `defineIdentityPlugin`, `definePlugin`, `defineRouterPlugin`, `hasDuplicateCookie`, `isAuthenticatedRequest`, `isSameOriginForm`, `isSameOriginPath`, `isSameOriginRequest`, `jsonLogger`, `markAuthenticatedRequest`, `parseCookies`, `pathnameOf`, `redactLogFields`, `rejected`, `replacedRequestOf`, `routePatternOverlap`, `serializeCookie`, `server`, `signValue`, `silentLogger`, `status`, `toFetchHandler`, `toLambdaHandler`, `toNetlifyHandler`, `toVercelHandler`, `unsignValue`, `urlPartsOf`, `writableResponse`
|
|
20087
|
+
`AdmissionController`, `AdmissionDecision`, `AnyServer`, `AuthHeaders`, `AuthMaybePromise`, `AuthenticationFailure`, `AuthenticationFailureReason`, `AuthenticationInput`, `AuthenticationResult`, `AuthenticationStage`, `AuthenticationSuccess`, `Context`, `ContextPlugin`, `CookieOptions`, `CookieSecret`, `DeclaredMountRoute`, `DefinePluginResult`, `DurableObjectNamespaceLike`, `ExecutionContext`, `FRAMEWORK_NAME`, `FetchApp`, `FrameworkError`, `FrameworkName`, `Handler`, `IdentityPlugin`, `InferInput`, `InferOutput`, `JoinRoutePath`, `LambdaEvent`, `LambdaHandler`, `LambdaResponse`, `LambdaV1Event`, `LambdaV2Event`, `ListenTlsOptions`, `LogFields`, `Logger`, `METHODS`, `McpPromptDescriptor`, `McpResourceDescriptor`, `Method`, `Middleware`, `MountFetchOptions`, `MountOptions`, `MountableApp`, `NetlifyEvent`, `NetlifyHandler`, `NifraFeatureVersion`, `NifraPlugin`, `NifraWebSocket`, `NodeRequestContext`, `NodeRequestHook`, `NodeResponseBodyHook`, `NodeResponseContext`, `NodeResponseHook`, `NodeServeOutcome`, `OnRequestResult`, `OpaqueMountDeclaration`, `Params`, `PlainRender`, `Platform`, `PlatformResponse`, `PluginTypeCollapsed`, `PrefixRegistry`, `Prettify`, `PromptArgument`, `PromptMessage`, `ROUTE_PATTERN_OVERLAP_MAX_STATES`, `RedactOptions`, `Registry`, `RequestPath`, `ResponseBodyHook`, `ResponseBodyReplacement`, `ResponseControls`, `ResponseFinalization`, `ResponseHeadersHook`, `ResponseHeadersView`, `ResponseMapFor`, `ResponseResult`, `RouteConfigError`, `RouteConfigErrorCode`, `RouteDescriptor`, `RouteInfo`, `RouteInfoFor`, `RouteMethod`, `RoutePatternOverlapLimitError`, `RouteSchema`, `Router`, `RouterMatch`, `RunningServer`, `SSEContext`, `SSEInit`, `SSEMessage`, `SSEStream`, `ScheduledController`, `ScheduledHandler`, `Server`, `ServerOptions`, `StandardIssue`, `StandardResult`, `StandardSchemaV1`, `StandardTypes`, `StandardWebSocket`, `StatusResponse`, `ToolAnnotations`, `TypedSSEStream`, `UrlParts`, `VERSION`, `ValidationOutcome`, `VercelHandler`, `Version`, `WebSocketContext`, `WebSocketData`, `WebSocketHandler`, `WebSocketUpgradeOutcome`, `authenticated`, `beforeHandler`, `commonSecretPatterns`, `cookieNamePrefix`, `defineContextPlugin`, `defineIdentityPlugin`, `definePlugin`, `defineRouterPlugin`, `hasDuplicateCookie`, `isAuthenticatedRequest`, `isSameOriginForm`, `isSameOriginPath`, `isSameOriginRequest`, `jsonLogger`, `markAuthenticatedRequest`, `parseCookies`, `pathnameOf`, `redactLogFields`, `rejected`, `replacedRequestOf`, `routePatternOverlap`, `routeTemplateOf`, `serializeCookie`, `server`, `signValue`, `silentLogger`, `status`, `toFetchHandler`, `toLambdaHandler`, `toNetlifyHandler`, `toVercelHandler`, `unsignValue`, `urlPartsOf`, `writableResponse`
|
|
19752
20088
|
|
|
19753
20089
|
## @nifrajs/cron
|
|
19754
20090
|
|
|
@@ -19756,7 +20092,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
19756
20092
|
|
|
19757
20093
|
## @nifrajs/deno
|
|
19758
20094
|
|
|
19759
|
-
`DenoServer`, `FetchHandler`, `ServeOptions`, `serve`
|
|
20095
|
+
`DenoServer`, `DenoStopOptions`, `FetchHandler`, `ServeOptions`, `serve`
|
|
19760
20096
|
|
|
19761
20097
|
## @nifrajs/devtools
|
|
19762
20098
|
|
|
@@ -19804,7 +20140,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
19804
20140
|
|
|
19805
20141
|
## @nifrajs/middleware
|
|
19806
20142
|
|
|
19807
|
-
`AdmissionControllerHandle`, `AdmissionEvidence`, `AdmissionOptions`, `AdmissionPolicy`, `AdmissionSnapshot`, `ApiKeyStaticOptions`, `ApiKeyVerifyOptions`, `AuthPlugin`, `BasicAuthPlugin`, `BasicAuthStaticOptions`, `BasicAuthVerifyOptions`, `BearerOptions`, `BodyLimitOptions`, `ByteRange`, `ByteRangeResult`, `CacheControlOptions`, `CacheOptions`, `CachedResponse`, `Composable`, `CompressionOptions`, `ConditionalResponseOptions`, `ContentPreference`, `CorsOptions`, `CsrfOptions`, `DurableCommandOptions`, `ETagOptions`, `HealthcheckOptions`, `IdempotencyClaim`, `IdempotencyOptions`, `IdempotencyRecord`, `IdempotencyStore`, `IpMatcher`, `IpRestrictionOptions`, `JwkKey`, `JwksOptions`, `JwtAlgorithm`, `JwtClaims`, `JwtHeader`, `JwtKeyResolver`, `JwtOptions`, `JwtPlugin`, `JwtVerificationKey`, `LanguageMatch`, `LanguageOptions`, `LoggerOptions`, `LoopDelayHistogram`, `LoopDelayMonitor`, `MemoryIdempotencyStore`, `MemoryIdempotencyStoreOptions`, `MemoryResponseCache`, `MemoryResponseCacheOptions`, `MemoryStore`, `MemoryStoreOptions`, `MethodOverrideOptions`, `MultipartBody`, `MultipartHeadersInit`, `MultipartPart`, `MultipartResponseOptions`, `OpenApiInfo`, `OpenApiOptions`, `OpenApiServer`, `OpenApiTag`, `OpenApiUiOptions`, `PoweredByOptions`, `PrettyJsonOptions`, `ProblemDetailsOptions`, `RangeResponseOptions`, `RateLimitOptions`, `RateLimitResult`, `RateLimitStore`, `RateLimitTier`, `RateLimitTiersOptions`, `RequestIdOptions`, `RequestLogFields`, `ResponseCacheStore`, `RouteLike`, `SecurityHeadersOptions`, `SecurityRequirement`, `ShedReason`, `TimingControls`, `TimingMetric`, `TimingOptions`, `TrailingSlashOptions`, `VerifiedJwt`, `VerifyJwtOptions`, `VerifyJwtResult`, `apiKey`, `appendTrailingSlash`, `basicAuth`, `bearer`, `bodyLimit`, `buildOpenApiDocument`, `cache`, `cacheControl`, `combine`, `compression`, `conditionalResponse`, `cors`, `createAdmissionController`, `createCsrfToken`, `createEventLoopLagSampler`, `csrf`, `durableCommand`, `etag`, `healthcheck`, `idempotency`, `ipRestriction`, `jwk`, `jwks`, `jwt`, `language`, `logger`, `methodOverride`, `multipartResponse`, `namedCombine`, `negotiateContentType`, `openapi`, `parseAcceptHeader`, `parseByteRange`, `pickLanguage`, `poweredBy`, `prettyJson`, `problemDetails`, `rangeResponse`, `rateLimit`, `rateLimitTiers`, `requestId`, `responseCache`, `securityHeaders`, `timing`, `trimTrailingSlash`, `tryVerifyJwt`, `verifyCsrfToken`, `verifyJwt`
|
|
20143
|
+
`AdmissionControllerHandle`, `AdmissionEvidence`, `AdmissionOptions`, `AdmissionPolicy`, `AdmissionSnapshot`, `ApiKeyStaticOptions`, `ApiKeyVerifyOptions`, `AuthPlugin`, `BasicAuthPlugin`, `BasicAuthStaticOptions`, `BasicAuthVerifyOptions`, `BearerOptions`, `BodyLimitOptions`, `ByteRange`, `ByteRangeResult`, `CacheControlOptions`, `CacheOptions`, `CachedResponse`, `Composable`, `CompressionOptions`, `ConditionalResponseOptions`, `ContentPreference`, `CorsOptions`, `CsrfOptions`, `DurableCommandOptions`, `ETagOptions`, `HealthcheckOptions`, `IdempotencyClaim`, `IdempotencyOptions`, `IdempotencyRecord`, `IdempotencyStore`, `IpMatcher`, `IpRestrictionOptions`, `JwkKey`, `JwksOptions`, `JwtAlgorithm`, `JwtClaims`, `JwtHeader`, `JwtKeyResolver`, `JwtOptions`, `JwtPlugin`, `JwtVerificationKey`, `LanguageMatch`, `LanguageOptions`, `LoggerOptions`, `LoopDelayHistogram`, `LoopDelayMonitor`, `MemoryIdempotencyStore`, `MemoryIdempotencyStoreOptions`, `MemoryResponseCache`, `MemoryResponseCacheOptions`, `MemoryStore`, `MemoryStoreOptions`, `MethodOverrideOptions`, `MultipartBody`, `MultipartHeadersInit`, `MultipartPart`, `MultipartResponseOptions`, `OpenApiInfo`, `OpenApiOptions`, `OpenApiServer`, `OpenApiTag`, `OpenApiUiOptions`, `PoweredByOptions`, `PrettyJsonOptions`, `ProblemDetailsOptions`, `RangeResponseOptions`, `RateLimitOptions`, `RateLimitResult`, `RateLimitStore`, `RateLimitTier`, `RateLimitTiersOptions`, `ReadinessCheck`, `ReadinessCheckOptions`, `ReadinessCheckResult`, `ReadinessCheckStatus`, `ReadinessReport`, `RequestIdOptions`, `RequestLogFields`, `ResponseCacheStore`, `RouteLike`, `SecurityHeadersOptions`, `SecurityRequirement`, `ShedReason`, `TimingControls`, `TimingMetric`, `TimingOptions`, `TrailingSlashOptions`, `VerifiedJwt`, `VerifyJwtOptions`, `VerifyJwtResult`, `apiKey`, `appendTrailingSlash`, `basicAuth`, `bearer`, `bodyLimit`, `buildOpenApiDocument`, `cache`, `cacheControl`, `combine`, `compression`, `conditionalResponse`, `cors`, `createAdmissionController`, `createCsrfToken`, `createEventLoopLagSampler`, `csrf`, `durableCommand`, `etag`, `healthcheck`, `idempotency`, `ipRestriction`, `jwk`, `jwks`, `jwt`, `language`, `logger`, `methodOverride`, `multipartResponse`, `namedCombine`, `negotiateContentType`, `openapi`, `parseAcceptHeader`, `parseByteRange`, `pickLanguage`, `poweredBy`, `prettyJson`, `problemDetails`, `rangeResponse`, `rateLimit`, `rateLimitTiers`, `requestId`, `responseCache`, `securityHeaders`, `timing`, `trimTrailingSlash`, `tryVerifyJwt`, `verifyCsrfToken`, `verifyJwt`
|
|
19808
20144
|
|
|
19809
20145
|
## @nifrajs/mock
|
|
19810
20146
|
|
|
@@ -19812,7 +20148,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
19812
20148
|
|
|
19813
20149
|
## @nifrajs/node
|
|
19814
20150
|
|
|
19815
|
-
`FetchHandler`, `NodeServer`, `RequestProtocol`, `RequestProtocolOption`, `ServeOptions`, `ServeStaticOptions`, `serve`
|
|
20151
|
+
`FetchHandler`, `NodeServer`, `NodeStopOptions`, `RequestProtocol`, `RequestProtocolOption`, `ServeOptions`, `ServeStaticOptions`, `serve`
|
|
19816
20152
|
|
|
19817
20153
|
## @nifrajs/otel
|
|
19818
20154
|
|