@nifrajs/cli 5.9.0 → 5.10.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 +57 -0
- package/dist/check-diagnostics.d.ts +1 -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 +1 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +8 -1
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +7 -2
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -8
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +1 -5
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +2 -21
- package/dist/command-catalog.js.map +1 -1
- package/dist/internal/source-facts.d.ts +30 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +127 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/load.d.ts +2 -0
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +5 -0
- package/dist/load.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-tool-meta.d.ts.map +1 -1
- package/dist/mcp-tool-meta.js +0 -1
- package/dist/mcp-tool-meta.js.map +1 -1
- package/dist/recipes/5.10.0.d.ts +12 -0
- package/dist/recipes/5.10.0.d.ts.map +1 -0
- package/dist/recipes/5.10.0.js +44 -0
- package/dist/recipes/5.10.0.js.map +1 -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 +3 -0
- package/dist/review.js.map +1 -1
- package/dist/rules/codes.d.ts +3 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +3 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +15 -0
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/internal-links.d.ts +5 -0
- package/dist/rules/internal-links.d.ts.map +1 -0
- package/dist/rules/internal-links.js +418 -0
- package/dist/rules/internal-links.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +20 -0
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/server-fn-namespace.d.ts +8 -0
- package/dist/rules/server-fn-namespace.d.ts.map +1 -0
- package/dist/rules/server-fn-namespace.js +43 -0
- package/dist/rules/server-fn-namespace.js.map +1 -0
- package/dist/rules/source-scan.d.ts +29 -0
- package/dist/rules/source-scan.d.ts.map +1 -0
- package/dist/rules/source-scan.js +38 -0
- package/dist/rules/source-scan.js.map +1 -0
- package/dist/rules/text-slot-boolean.d.ts.map +1 -1
- package/dist/rules/text-slot-boolean.js +21 -43
- package/dist/rules/text-slot-boolean.js.map +1 -1
- package/dist/source-rewrites.d.ts.map +1 -1
- package/dist/source-rewrites.js +118 -3
- package/dist/source-rewrites.js.map +1 -1
- package/dist/typecheck-coverage.d.ts +9 -0
- package/dist/typecheck-coverage.d.ts.map +1 -1
- package/dist/typecheck-coverage.js +16 -0
- package/dist/typecheck-coverage.js.map +1 -1
- package/docs/examples.json +19 -7
- package/docs/llms-full.txt +555 -200
- package/docs/types.json +560 -115
- package/package.json +11 -11
- package/src/check-diagnostics.ts +5 -0
- package/src/check-scan.ts +9 -1
- package/src/check.ts +15 -3
- package/src/cli.ts +16 -8
- package/src/command-catalog.ts +2 -26
- package/src/internal/source-facts.ts +155 -0
- package/src/load.ts +9 -0
- package/src/mcp-http.ts +1 -1
- package/src/mcp-tool-meta.ts +0 -1
- package/src/recipes/5.10.0.ts +45 -0
- package/src/recipes/index.ts +2 -0
- package/src/review.ts +3 -0
- package/src/rules/codes.ts +3 -0
- package/src/rules/explanations.ts +15 -0
- package/src/rules/internal-links.ts +490 -0
- package/src/rules/legacy.ts +21 -0
- package/src/rules/server-fn-namespace.ts +47 -0
- package/src/rules/source-scan.ts +66 -0
- package/src/rules/text-slot-boolean.ts +26 -42
- package/src/source-rewrites.ts +133 -4
- package/src/typecheck-coverage.ts +23 -0
- package/dist/sync-routes.d.ts +0 -29
- package/dist/sync-routes.d.ts.map +0 -1
- package/dist/sync-routes.js +0 -56
- package/dist/sync-routes.js.map +0 -1
- package/src/sync-routes.ts +0 -70
package/docs/llms-full.txt
CHANGED
|
@@ -47,7 +47,7 @@ cd my-app
|
|
|
47
47
|
bun install
|
|
48
48
|
bun run dev`
|
|
49
49
|
|
|
50
|
-
See the
|
|
50
|
+
See the CLI guide for other templates, UI frameworks, and deploy
|
|
51
51
|
targets.
|
|
52
52
|
|
|
53
53
|
### One app, two agent loops
|
|
@@ -55,8 +55,8 @@ targets.
|
|
|
55
55
|
A coding agent can inspect the live project, change it, run real requests, and prove the result.
|
|
56
56
|
A user-facing agent can discover explicit page tools, stream progress into the UI, predict a
|
|
57
57
|
state change, and reconcile it with the server. Both use the same typed capabilities and
|
|
58
|
-
verification boundary. Start with the
|
|
59
|
-
|
|
58
|
+
verification boundary. Start with the agent layer or the
|
|
59
|
+
WebMCP & predictive UI guide when you are ready to add them.
|
|
60
60
|
|
|
61
61
|
### A backend-only alternative
|
|
62
62
|
|
|
@@ -104,12 +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, then
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
cache as you grow, then live refresh,
|
|
108
|
+
keep-alive pages,
|
|
109
|
+
server components and
|
|
110
|
+
partial prerendering where a page needs them. The
|
|
111
111
|
data model is framework-agnostic, so the renderer stays replaceable. See
|
|
112
|
-
|
|
112
|
+
Project structure for where code lives.
|
|
113
113
|
|
|
114
114
|
```ts
|
|
115
115
|
// routes/index.backend.ts - the loader runs on the server (in-process during SSR, no network),
|
|
@@ -150,9 +150,9 @@ export default function Page({ data }: Route.ComponentProps) {
|
|
|
150
150
|
-
|
|
151
151
|
**Vercel Edge, AWS Lambda, or a static host** - `nifra build --target vercel`,
|
|
152
152
|
`@nifrajs/aws-lambda`, or `nifra build --target static` for a
|
|
153
|
-
prerendered site. See
|
|
153
|
+
prerendered site. See Deployment.
|
|
154
154
|
|
|
155
|
-
See the
|
|
155
|
+
See the benchmarks for how it performs.
|
|
156
156
|
|
|
157
157
|
## Nifra vs. other frameworks - the honest comparison
|
|
158
158
|
|
|
@@ -202,23 +202,23 @@ Across the board, Nifra ships the modern full-stack feature set on all five UI f
|
|
|
202
202
|
|
|
203
203
|
-
|
|
204
204
|
File routing (dynamic / catch-all / groups / optional) + nested layouts, typed search
|
|
205
|
-
params, and a route
|
|
205
|
+
params, and a route opened in a modal.
|
|
206
206
|
|
|
207
207
|
-
|
|
208
208
|
SSR · SSG · ISR, streaming SSR with out-of-order Suspense,
|
|
209
|
-
|
|
209
|
+
partial prerendering, view
|
|
210
210
|
transitions, and a ~0 KB-client vanilla adapter with
|
|
211
|
-
|
|
211
|
+
islands and slot swaps.
|
|
212
212
|
|
|
213
213
|
-
|
|
214
|
-
Loaders + actions +
|
|
214
|
+
Loaders + actions + server functions (typed
|
|
215
215
|
`serverFn` RPC, server code never shipped to the browser) + progressive-enhancement
|
|
216
216
|
forms; `defer()` / `<Await>` streaming data; query cache, optimistic
|
|
217
217
|
UI, concurrent fetchers, revalidation.
|
|
218
218
|
|
|
219
219
|
-
|
|
220
|
-
|
|
221
|
-
changed keys) and
|
|
220
|
+
Live refresh (a publish reloads only the loaders that read the
|
|
221
|
+
changed keys) and keep-alive pages (back and forward bring
|
|
222
222
|
the same page back, state and scroll included).
|
|
223
223
|
|
|
224
224
|
- Head/meta, hover/focus prefetch, scroll restoration.
|
|
@@ -234,11 +234,11 @@ of one.
|
|
|
234
234
|
### Server code and server-only views
|
|
235
235
|
|
|
236
236
|
Nifra provides typed loaders and actions, streaming SSR, islands and typed
|
|
237
|
-
|
|
237
|
+
server functions. Server functions keep their
|
|
238
238
|
implementation, secrets and database handles off the browser and use the same validated
|
|
239
239
|
mutation API across the supported UI libraries.
|
|
240
240
|
|
|
241
|
-
The optional
|
|
241
|
+
The optional server-components pipeline adds
|
|
242
242
|
server-only views and state-preserving refresh. React uses native RSC/Flight; Vue, Svelte,
|
|
243
243
|
Solid and Preact use their native islands in validated server-rendered ranges. All five
|
|
244
244
|
adapters pass the same certification, and a partially prerendered page can show a server
|
|
@@ -247,14 +247,14 @@ component in a hole. Server functions remain the mutation API; native React
|
|
|
247
247
|
|
|
248
248
|
### Caching and fresh data
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
SSG and ISR cover pages that change rarely. Three more tools
|
|
251
251
|
cover the pages that do not:
|
|
252
252
|
|
|
253
253
|
-
|
|
254
254
|
**
|
|
255
|
-
|
|
255
|
+
Partial prerendering
|
|
256
256
|
**
|
|
257
|
-
(
|
|
257
|
+
(all five adapters). The part of a page that is the same for every visitor is
|
|
258
258
|
built once, cached and sent at once; each per-visitor hole streams into it as its own loader
|
|
259
259
|
settles. The build refuses a shell whose code reaches a module that reads the visitor, and
|
|
260
260
|
`checkShellCanaries` looks for visitor data in a served shell. A shared hole, such
|
|
@@ -263,7 +263,7 @@ as partial prerendering under Cache Components.
|
|
|
263
263
|
|
|
264
264
|
-
|
|
265
265
|
**
|
|
266
|
-
|
|
266
|
+
Live refresh
|
|
267
267
|
**
|
|
268
268
|
. A loader names the keys its data read with `live(...keys)`; a
|
|
269
269
|
`publish`, or an action's `revalidate(paths, data, { keys })`,
|
|
@@ -280,7 +280,7 @@ the write. A page store shared between processes is signed.
|
|
|
280
280
|
|
|
281
281
|
-
|
|
282
282
|
**
|
|
283
|
-
|
|
283
|
+
Keep-alive
|
|
284
284
|
**
|
|
285
285
|
(all five adapters). `export const keepAlive = true` keeps a page mounted after
|
|
286
286
|
the visitor leaves it; back and forward bring it back with its state, scroll and focus.
|
|
@@ -427,7 +427,7 @@ chain (so `n` optionals → `2ⁿ` patterns).
|
|
|
427
427
|
-
|
|
428
428
|
`x.backend.ts` beside a page or layout is its server half: `loader`,
|
|
429
429
|
`action`, their output schemas, and the other server-only exports. It never
|
|
430
|
-
reaches the browser - see
|
|
430
|
+
reaches the browser - see Project structure.
|
|
431
431
|
|
|
432
432
|
-
|
|
433
433
|
`_404.tsx` renders unmatched paths, and whatever a loader answers with
|
|
@@ -519,7 +519,7 @@ routes/
|
|
|
519
519
|
Each page default-exports a component; an optional `meta` export drives
|
|
520
520
|
`<head>` (applied on SSR and on client navigation). Its data comes from a
|
|
521
521
|
`loader` in its `.backend.ts` half - see
|
|
522
|
-
|
|
522
|
+
Loaders & actions.
|
|
523
523
|
|
|
524
524
|
A layout's `meta` receives its own loader's data as `data`, the value its
|
|
525
525
|
component renders, or `null` when the layout has no loader. The page's data is
|
|
@@ -560,12 +560,12 @@ before a nested `_404` there. Middleware higher in the tree runs first.
|
|
|
560
560
|
|
|
561
561
|
```ts
|
|
562
562
|
// routes/account/_layout.backend.ts - runs before every page under /account
|
|
563
|
-
import { type RouteMiddleware, redirect } from "@nifrajs/web"
|
|
563
|
+
import { type RouteMiddleware, rawHref, redirect } from "@nifrajs/web"
|
|
564
564
|
|
|
565
565
|
export const middleware: RouteMiddleware = ({ request, set }) => {
|
|
566
566
|
set.headers["cache-control"] = "private, no-store"
|
|
567
567
|
const signedIn = request.headers.get("cookie")?.includes("session=") ?? false
|
|
568
|
-
return signedIn ? undefined : redirect("/login")
|
|
568
|
+
return signedIn ? undefined : redirect(rawHref("/login"))
|
|
569
569
|
}
|
|
570
570
|
```
|
|
571
571
|
|
|
@@ -692,15 +692,93 @@ React/Preact, a `Ref` on Vue, an accessor on Solid/Svelte. For imperative reads
|
|
|
692
692
|
writes of the raw query, `useSearchParams()` mirrors react-router's
|
|
693
693
|
`[params, setParams]` tuple.
|
|
694
694
|
|
|
695
|
-
To WRITE search, `
|
|
696
|
-
`navigate({ to: "/reports", search: { page: 2 } })
|
|
697
|
-
|
|
698
|
-
`
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
`
|
|
703
|
-
|
|
695
|
+
To WRITE search, build the link with `href` and hand it to `useNavigate`:
|
|
696
|
+
`navigate(href({ to: "/reports", search: { page: 2 } }))`. `href` and
|
|
697
|
+
`rawHref` are exported by every adapter's router entry (
|
|
698
|
+
`@nifrajs/web-<framework>/router`). `nifra dev`,
|
|
699
|
+
`nifra build`, `nifra check` and `nifra types` write
|
|
700
|
+
`.nifra/types/routes.d.ts`, which maps every route pattern to its params and its
|
|
701
|
+
schema output, and each route's generated `./+types` module loads it. So
|
|
702
|
+
`to` is one of those patterns, `params` holds that route's params, and
|
|
703
|
+
`search` is typed against its schema: a misspelt route, a missing param and a wrong
|
|
704
|
+
search shape are compile errors, and a changed `searchSchema` shows up as a
|
|
705
|
+
`tsc` error at the stale call. A route without a `searchSchema` takes any
|
|
706
|
+
`search`.
|
|
707
|
+
|
|
708
|
+
Each param is encoded as one path segment, so a value such as `a/b` or
|
|
709
|
+
`//evil.com` stays inside the segment and never changes where the link goes. A
|
|
710
|
+
param that is missing, empty, `.`, `..` or an unpaired surrogate throws a
|
|
711
|
+
`TypeError` naming it. `navigate` takes only an `href` result,
|
|
712
|
+
or a history delta such as `navigate(-1)`; a string or a template literal is a
|
|
713
|
+
compile error. So do React's `Link`, `NavLink` and `Navigate`
|
|
714
|
+
(`<Link to={href({ to: "/pricing" })}>`) and the server's
|
|
715
|
+
`redirect()`; when `to` is not a same-origin path,
|
|
716
|
+
`Link` and `NavLink` render the anchor without an `href`,
|
|
717
|
+
and `Navigate` and `setSearchParams` do not navigate; each logs a
|
|
718
|
+
`console.error` that names the call and never the value. `redirect`
|
|
719
|
+
takes an off-origin location with `{ external: true }`, which still refuses
|
|
720
|
+
one holding a line break. For a same-origin path built elsewhere - a CMS link,
|
|
721
|
+
`/llms.txt` - `rawHref("/llms.txt")` checks it (one leading
|
|
722
|
+
`/`, no backslash or control character) and returns the same type. A link to
|
|
723
|
+
another site is a plain `<a href>`. A path that comes from outside is
|
|
724
|
+
checked where it is read: `rawHref` throws a `TypeError` for one that is
|
|
725
|
+
not same-origin, so catch it at that call when a field cannot be trusted. A value that gets
|
|
726
|
+
past it as a forged `Href` costs only its own link.
|
|
727
|
+
|
|
728
|
+
### Moving existing links to href()
|
|
729
|
+
|
|
730
|
+
A link written as a string is not checked: `navigate("/pricng")` and
|
|
731
|
+
`<a href="/pricng">` compile and then 404. Moving one is mechanical.
|
|
732
|
+
|
|
733
|
+
```tsx
|
|
734
|
+
// doc-check: skip - routes of your own app; one line per call, before and after.
|
|
735
|
+
import { href, rawHref } from "@nifrajs/web-react/router"
|
|
736
|
+
|
|
737
|
+
navigate(`/users/${id}?tab=posts`)
|
|
738
|
+
navigate(href({ to: "/users/:id", params: { id }, search: { tab: "posts" } }))
|
|
739
|
+
|
|
740
|
+
<a href="/pricing">Pricing</a>
|
|
741
|
+
<a href={href({ to: "/pricing" })}>Pricing</a>
|
|
742
|
+
|
|
743
|
+
<Link to="/docs#install">Install</Link>
|
|
744
|
+
<Link to={href({ to: "/docs", hash: "install" })}>Install</Link>
|
|
745
|
+
|
|
746
|
+
throw redirect("/login")
|
|
747
|
+
throw redirect(href({ to: "/login" }))
|
|
748
|
+
|
|
749
|
+
navigate(cmsLink) // a same-origin path built elsewhere
|
|
750
|
+
navigate(rawHref(cmsLink))
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
A leftover `navigate("/x")`, `<Link to="/x">` or
|
|
754
|
+
`redirect("/x")` is a compile error at the call, so `tsc` lists what is
|
|
755
|
+
left. A plain `<a href="/x">` is not an error, so search for
|
|
756
|
+
`href="/` and `href={`/` too; a link that opens another site stays
|
|
757
|
+
an `<a href>`. This site, the examples and the starters are held to it by a
|
|
758
|
+
test that fails on a literal internal anchor.
|
|
759
|
+
|
|
760
|
+
`nifra check` finds the plain anchors in your app too, and reads the route table to
|
|
761
|
+
tell two cases apart. `NF-C057` (a warning) is a path that no page, no backend route
|
|
762
|
+
and no file in `public/` serves: the link is a 404, and the message names the
|
|
763
|
+
nearest page when it is a typo away. `NF-C058` (info) is a path that is a page
|
|
764
|
+
today; the message gives the `href()` call that replaces it. A template literal such
|
|
765
|
+
as ``/users/${id}`` is judged by its shape and never reported as dead, since the
|
|
766
|
+
route it builds may live outside the file routes. Links in `.tsx`, `.vue`
|
|
767
|
+
and `.svelte` files are read. Raise, lower or silence either code with
|
|
768
|
+
`rules` in `nifra.config`, or keep one link as written with
|
|
769
|
+
`rawHref()` or `// nifra-expect NF-C058: <reason>` above the
|
|
770
|
+
attribute (`<!-- nifra-expect NF-C058: <reason> -->` above the anchor in a
|
|
771
|
+
`.vue` or `.svelte` template). A backend mounted under
|
|
772
|
+
`apiPrefix` counts as serving its paths, read from `backend/framework.ts`
|
|
773
|
+
or `nifra.config.ts`; when either holds a value `check` cannot read, no
|
|
774
|
+
link is reported dead. `.jsx` files and an `href` built by a function are
|
|
775
|
+
not read.
|
|
776
|
+
|
|
777
|
+
The table is a generated file, `.nifra/types/routes.d.ts`. A program in which no route
|
|
778
|
+
imports a `./+types/...` module does not load it, and `to` then accepts no
|
|
779
|
+
route at all, and `nifra check` warns. List `.nifra/types/routes.d.ts` under
|
|
780
|
+
the tsconfig `files`: the `**` globs skip a dot directory, and a
|
|
781
|
+
`files` entry is not filtered by `exclude`.
|
|
704
782
|
|
|
705
783
|
### Prefetching
|
|
706
784
|
|
|
@@ -730,7 +808,7 @@ around it (the nearest one wins), says when:
|
|
|
730
808
|
</nav>
|
|
731
809
|
|
|
732
810
|
// React's <Link> takes it as a prop.
|
|
733
|
-
<Link to="/pricing" prefetch="render">Pricing</Link>
|
|
811
|
+
<Link to={href({ to: "/pricing" })} prefetch="render">Pricing</Link>
|
|
734
812
|
```
|
|
735
813
|
|
|
736
814
|
Warmed data is used by a click within 30 seconds; after that the click loads the route
|
|
@@ -840,9 +918,10 @@ type it with that route's `LoaderData`. `routes/photos/[id].tsx`
|
|
|
840
918
|
stays an ordinary page.
|
|
841
919
|
|
|
842
920
|
-
|
|
843
|
-
Back closes the modal and forward reopens it.
|
|
844
|
-
|
|
845
|
-
|
|
921
|
+
Back closes the modal and forward reopens it. Closing shows the page underneath as it was,
|
|
922
|
+
with its loader data and boundaries, without fetching it again; a page loaded for a
|
|
923
|
+
previous visitor loads again. A link inside the modal to another matching URL replaces its
|
|
924
|
+
content, and back steps through each one. Navigating anywhere else closes it.
|
|
846
925
|
|
|
847
926
|
-
|
|
848
927
|
A reload, a shared link, or a navigation from a page outside the declaring layout or page
|
|
@@ -957,7 +1036,7 @@ arktype, …); outputs are inferred end-to-end.
|
|
|
957
1036
|
|
|
958
1037
|
Everything on this page is just `@nifrajs/core` - no frontend, no build step. Use Nifra
|
|
959
1038
|
as a standalone backend the way you'd use Hono or Elysia, deploy it to any runtime, and reach
|
|
960
|
-
for
|
|
1039
|
+
for the frontend adapters only if and when you go full-stack.
|
|
961
1040
|
|
|
962
1041
|
### An inline server
|
|
963
1042
|
|
|
@@ -1592,9 +1671,9 @@ client sends nothing rather than reach a route the call does not name.
|
|
|
1592
1671
|
`.ws()` throws.
|
|
1593
1672
|
|
|
1594
1673
|
The same client runs in the browser and on the server. During SSR, a route's
|
|
1595
|
-
|
|
1596
|
-
`ctx.api`. Next:
|
|
1597
|
-
|
|
1674
|
+
loader calls it **in-process** (no network hop) via
|
|
1675
|
+
`ctx.api`. Next: file routing,
|
|
1676
|
+
loaders & actions, and plugins.
|
|
1598
1677
|
|
|
1599
1678
|
## Nifra - Loaders & actions
|
|
1600
1679
|
|
|
@@ -1615,9 +1694,9 @@ leaves the server. Declare a timestamp as `t.date()` and the page gets a
|
|
|
1615
1694
|
field that is any JSON value, passed through whole - a tool-call payload or a settings blob
|
|
1616
1695
|
the page does not pick apart. A loader without a schema is flagged by
|
|
1617
1696
|
`nifra check`. See
|
|
1618
|
-
|
|
1697
|
+
Project structure for the route pair. A loader that names the
|
|
1619
1698
|
data it read with `live(...keys)` reloads on its own when that data changes - see
|
|
1620
|
-
|
|
1699
|
+
Live refresh.
|
|
1621
1700
|
|
|
1622
1701
|
```ts
|
|
1623
1702
|
// routes/users/[id].backend.ts - a loader runs on the server: in-process during SSR (no network
|
|
@@ -1689,7 +1768,7 @@ loader **revalidates** (no full reload); with JS disabled the native form POST r
|
|
|
1689
1768
|
`actionData`, bounded by `actionOutput`.
|
|
1690
1769
|
|
|
1691
1770
|
A reload of the page on screen (an action's revalidation, `invalidate()`, a
|
|
1692
|
-
|
|
1771
|
+
live refresh, a fetcher loading its path again) keeps every part of `data` and the
|
|
1693
1772
|
layouts' data that it did not change as the same object, with one bound: an array none of
|
|
1694
1773
|
whose first 32 elements is unchanged is replaced whole, so a reload that changed every row
|
|
1695
1774
|
stops comparing early. A row kept this way keeps its DOM and component state: a Solid
|
|
@@ -1752,7 +1831,7 @@ in middleware. In development, nifra warns the first time a layout loader withou
|
|
|
1752
1831
|
`gate` refuses a request with a redirect, a `Response`, or a 401 or 403,
|
|
1753
1832
|
and `nifra check` reports one whose loader refuses in its own body (NF-C042). A
|
|
1754
1833
|
`_layout.backend.ts` that exports `middleware` guards a directory, with
|
|
1755
|
-
or without a layout component - see
|
|
1834
|
+
or without a layout component - see Route middleware.
|
|
1756
1835
|
|
|
1757
1836
|
A layout's `shouldRevalidate` overrides that default. It runs on the server and
|
|
1758
1837
|
receives `defaultShouldRevalidate` with the URL and params being left and the ones
|
|
@@ -1815,8 +1894,8 @@ export async function loader() {
|
|
|
1815
1894
|
```
|
|
1816
1895
|
|
|
1817
1896
|
For optimistic UI, concurrent fetchers, and a keyed query cache, the same primitives compose
|
|
1818
|
-
on all five adapters: see
|
|
1819
|
-
|
|
1897
|
+
on all five adapters: see fetchers and
|
|
1898
|
+
the query cache.
|
|
1820
1899
|
|
|
1821
1900
|
## Nifra - Server functions
|
|
1822
1901
|
|
|
@@ -1896,9 +1975,10 @@ The namespace becomes a URL segment, so it is constrained to lowercase dot/dash
|
|
|
1896
1975
|
branded export mounts at `/_nifra/fn/<namespace>/<exportName>`; anything
|
|
1897
1976
|
in the module that is not a server function is ignored rather than mounted.
|
|
1898
1977
|
|
|
1899
|
-
One thing worth knowing: the namespace you pass here and the `*.fn.ts` filename
|
|
1900
|
-
|
|
1901
|
-
|
|
1978
|
+
One thing worth knowing: the namespace you pass here and the `*.fn.ts` filename must
|
|
1979
|
+
agree, or the call 404s. The compiler does not compare them, but `nifra check`
|
|
1980
|
+
reports a mismatch as NF-C056 when the module is imported with
|
|
1981
|
+
`import * as todos from "./todos.fn"` and mounted in the same file. The build fails on a
|
|
1902
1982
|
filename that is not a valid namespace (`todoItems.fn.ts`; use
|
|
1903
1983
|
`todo-items.fn.ts`). Two files with one basename (`admin/todos.fn.ts`
|
|
1904
1984
|
and `user/todos.fn.ts`) share the namespace: both mount, and an export name they
|
|
@@ -1996,8 +2076,8 @@ nifra assure
|
|
|
1996
2076
|
✖ POST /_nifra/fn/todos/addTodo (authenticated-write) is missing nifra.authenticated
|
|
1997
2077
|
```
|
|
1998
2078
|
|
|
1999
|
-
See
|
|
2000
|
-
against, and
|
|
2079
|
+
See effect provenance for what the declaration is checked
|
|
2080
|
+
against, and the verification ladder for where this sits.
|
|
2001
2081
|
|
|
2002
2082
|
### Cost
|
|
2003
2083
|
|
|
@@ -2068,7 +2148,7 @@ const anyPending = useFetchers().some((f) => f.snapshot().pending)
|
|
|
2068
2148
|
```
|
|
2069
2149
|
|
|
2070
2150
|
A fetcher holds nothing for the next visitor: `identityChanged()` returns every
|
|
2071
|
-
fetcher to idle, and a load still in flight loads once more for the new visitor. In an app with a
|
|
2151
|
+
fetcher to idle, and a load still in flight loads once more for the new visitor. In an app with a keepAlive route, so
|
|
2072
2152
|
does the identity epoch cookie a sign-in or sign-out response rotates, on the next
|
|
2073
2153
|
`useFetcher` read.
|
|
2074
2154
|
|
|
@@ -2132,7 +2212,7 @@ export default function Product({ data }: Route.ComponentProps) {
|
|
|
2132
2212
|
This is request-time progressive SSR: the whole page, shell included, renders for each
|
|
2133
2213
|
request, and deferred values remain request-scoped. To serve the part that is the same for
|
|
2134
2214
|
every visitor from a cache and stream only the per-visitor parts, use
|
|
2135
|
-
|
|
2215
|
+
partial prerendering.
|
|
2136
2216
|
|
|
2137
2217
|
### SSG - prerender at build
|
|
2138
2218
|
|
|
@@ -2342,7 +2422,7 @@ and is reported once to `onInvalidationError`.
|
|
|
2342
2422
|
A per-request CSP nonce makes a page uncacheable. For a strict policy under ISR, give
|
|
2343
2423
|
`createWebApp` a `csp` from `createCspPolicy` instead of a
|
|
2344
2424
|
`nonce`: constant scripts are allowed by hash, so only a page that needs a nonce
|
|
2345
|
-
carries one - see
|
|
2425
|
+
carries one - see A strict CSP that still caches.
|
|
2346
2426
|
|
|
2347
2427
|
A page that must not be cached as a whole, because it is personalized or carries a nonce, can
|
|
2348
2428
|
still cache the data its loader reads. Wrap the expensive call in `cache.wrap` from
|
|
@@ -2445,14 +2525,14 @@ cache. Pass the same `draftSecret` to `createWebApp` and
|
|
|
2445
2525
|
`withISR`; a forged or tampered cookie fails the constant-time signature check.
|
|
2446
2526
|
|
|
2447
2527
|
```ts
|
|
2448
|
-
// doc-check: skip - fragment spanning three files: your `app`, `env`,
|
|
2528
|
+
// doc-check: skip - fragment spanning three files: your `app`, `env`, and route `slug`.
|
|
2449
2529
|
// 1. Mount the preview entry point your CMS links to. It checks the token in CONSTANT TIME,
|
|
2450
2530
|
// sets the signed HttpOnly cookie, and refuses an off-site ?to= (an open redirect otherwise).
|
|
2451
|
-
import { previewEndpoint, disableDraft } from "@nifrajs/web"
|
|
2531
|
+
import { previewEndpoint, disableDraft, redirect, rawHref } from "@nifrajs/web"
|
|
2452
2532
|
|
|
2453
2533
|
const preview = previewEndpoint({ secret: env.PREVIEW_TOKEN, draftSecret: env.DRAFT_SECRET })
|
|
2454
2534
|
app.get("/api/preview", (c) => preview(c.req)) // ?token=…&to=/posts/hello
|
|
2455
|
-
app.get("/api/preview/exit", (c) => (disableDraft(c), redirect("/")))
|
|
2535
|
+
app.get("/api/preview/exit", (c) => (disableDraft(c), redirect(rawHref("/"))))
|
|
2456
2536
|
// Gating it yourself instead? Use enableDraft(c, env.DRAFT_SECRET) AFTER your own check - and
|
|
2457
2537
|
// compare the token in constant time, since === leaks it one character at a time.
|
|
2458
2538
|
|
|
@@ -2534,9 +2614,8 @@ a metric instead of its final value - aggregate those with `delta` or
|
|
|
2534
2614
|
Content that's the same for everyone and changes rarely → **SSG**. Content that changes
|
|
2535
2615
|
occasionally and can tolerate seconds-to-minutes of staleness → **ISR**. Per-request or
|
|
2536
2616
|
per-user content → plain **SSR** (the default). A page that is mostly shared with a few
|
|
2537
|
-
per-visitor parts →
|
|
2538
|
-
|
|
2539
|
-
is open, without a reload, adds [live refresh](/docs/live) to any of them.
|
|
2617
|
+
per-visitor parts → partial prerendering. You can mix them in one app, route by route. A page that must update while it
|
|
2618
|
+
is open, without a reload, adds live refresh to any of them.
|
|
2540
2619
|
|
|
2541
2620
|
## Nifra - Hydration & pre-hydration forms
|
|
2542
2621
|
|
|
@@ -3040,10 +3119,10 @@ export default function Page({ data }: Route.ComponentProps) {
|
|
|
3040
3119
|
The same `defer()` works in actions and across client-side soft navigations (an
|
|
3041
3120
|
NDJSON stream settles the deferred values), and it's framework-agnostic - React
|
|
3042
3121
|
`<Suspense>` and Solid's streaming both drive it from one core. See
|
|
3043
|
-
|
|
3122
|
+
Frameworks for which adapters stream the boundary in the
|
|
3044
3123
|
server HTML.
|
|
3045
3124
|
|
|
3046
|
-
|
|
3125
|
+
Partial prerendering streams the same
|
|
3047
3126
|
way from a cached shell: the part of the page every visitor shares goes out at once from the
|
|
3048
3127
|
cache, and each per-visitor hole streams in as its loader settles.
|
|
3049
3128
|
|
|
@@ -3135,7 +3214,7 @@ feed.close()
|
|
|
3135
3214
|
|
|
3136
3215
|
## Nifra - Query cache
|
|
3137
3216
|
|
|
3138
|
-
> Nifra's keyed query cache:
|
|
3217
|
+
> Nifra's cross-framework keyed query cache: reactive queries, mutations, infinite lists, and SSR hydration.
|
|
3139
3218
|
|
|
3140
3219
|
For client-side data that isn't a route loader - lists, widgets, anything refetchable -
|
|
3141
3220
|
Nifra ships a keyed query cache (TanStack-Query-style), agnostic across all five adapters.
|
|
@@ -3146,8 +3225,9 @@ Nifra ships a keyed query cache (TanStack-Query-style), agnostic across all five
|
|
|
3146
3225
|
`createQuery(key, fn)` (Solid), each from the adapter's `/query`
|
|
3147
3226
|
entry, subscribe a component to a cached, keyed query. Concurrent reads of the same key
|
|
3148
3227
|
**dedup** into one in-flight fetch; results are cached with a `staleTime` (the
|
|
3149
|
-
third argument's option), a background refetch, and bounded GC.
|
|
3150
|
-
|
|
3228
|
+
third argument's option), a background refetch, and bounded GC. The query cache also has
|
|
3229
|
+
mutation and infinite-query bindings across the adapters, using each framework's reactive
|
|
3230
|
+
model.
|
|
3151
3231
|
|
|
3152
3232
|
```ts
|
|
3153
3233
|
import { useQuery, useQueryClient } from "@nifrajs/web-react/query"
|
|
@@ -3169,13 +3249,90 @@ function CreateUser() {
|
|
|
3169
3249
|
}
|
|
3170
3250
|
```
|
|
3171
3251
|
|
|
3252
|
+
### Mutations and infinite queries
|
|
3253
|
+
|
|
3254
|
+
React and Preact expose `useMutation` and `useInfiniteQuery`. Vue
|
|
3255
|
+
exposes composables whose reactive state is read from refs. Svelte returns readable stores,
|
|
3256
|
+
and Solid exposes `createMutation` and `createInfiniteQuery` accessors.
|
|
3257
|
+
Each mutation has `mutate`, `mutateAsync`, `reset`, and
|
|
3258
|
+
`cancel`; each paged query exposes next/previous-page controls and page-availability
|
|
3259
|
+
state. Mutations remain client state bindings: the server action or endpoint still enforces
|
|
3260
|
+
authorization. Mutation functions receive a shared context with a `signal` as
|
|
3261
|
+
their second argument. `onMutate` receives that context second;
|
|
3262
|
+
`onSuccess` and `onError` receive it third; and `onSettled`
|
|
3263
|
+
receives it fourth. Pass `context.signal` to `fetch` and check it before
|
|
3264
|
+
side effects after an `await`. `cancel` aborts that signal, rejects the local promise, and
|
|
3265
|
+
discards local results; the request or server action only stops if it honors the signal, and accepted server work may
|
|
3266
|
+
finish.
|
|
3267
|
+
|
|
3268
|
+
```ts
|
|
3269
|
+
// React / Preact: hooks with a promise-returning mutation.
|
|
3270
|
+
// The mutation function receives a context with a shared AbortSignal as its second argument.
|
|
3271
|
+
const saveProfile = async (profile, { signal }) => {
|
|
3272
|
+
const response = await fetch("/api/profile", {
|
|
3273
|
+
method: "PUT",
|
|
3274
|
+
headers: { "content-type": "application/json" },
|
|
3275
|
+
body: JSON.stringify(profile),
|
|
3276
|
+
signal,
|
|
3277
|
+
})
|
|
3278
|
+
if (!response.ok) throw new Error("Profile save failed")
|
|
3279
|
+
return response
|
|
3280
|
+
}
|
|
3281
|
+
const save = useMutation(saveProfile)
|
|
3282
|
+
await save.mutateAsync(profile)
|
|
3283
|
+
|
|
3284
|
+
// Vue: state is a ref; read it with .value.
|
|
3285
|
+
const save = useMutation(saveProfile)
|
|
3286
|
+
await save.mutateAsync(profile)
|
|
3287
|
+
save.state.value.status
|
|
3288
|
+
|
|
3289
|
+
// Svelte: mutation and infinite-query bindings are readable stores.
|
|
3290
|
+
const save = useMutation(saveProfile)
|
|
3291
|
+
await save.mutateAsync(profile)
|
|
3292
|
+
// In markup, read $save.status.
|
|
3293
|
+
|
|
3294
|
+
// Solid: state is exposed through accessors.
|
|
3295
|
+
const save = createMutation(saveProfile)
|
|
3296
|
+
await save.mutateAsync(profile)
|
|
3297
|
+
save.state().status
|
|
3298
|
+
```
|
|
3299
|
+
|
|
3300
|
+
### SSR cache hydration
|
|
3301
|
+
|
|
3302
|
+
Query-cache hydration is separate from hydrating server-rendered markup. Create a fresh query
|
|
3303
|
+
client for each server request, prefetch the data, and pass its dehydrated state through Nifra
|
|
3304
|
+
route data. React and Preact use `QueryClientProvider` with
|
|
3305
|
+
`HydrationBoundary`; Solid accepts the state on `QueryClientProvider`;
|
|
3306
|
+
Vue and Svelte call `provideQueryClient(client, state)` in the app root before child
|
|
3307
|
+
queries initialize. The browser may keep one client for the app. Query state is cleared on
|
|
3308
|
+
identity changes, and in-flight mutation results are discarded at that boundary.
|
|
3309
|
+
|
|
3310
|
+
Every value included by `dehydrate` is serialized to the browser and is visible to
|
|
3311
|
+
that visitor, so `dehydrate` sends nothing by default. Pass
|
|
3312
|
+
`shouldDehydrateQuery` to name the regular and infinite queries that are safe to
|
|
3313
|
+
send; pass `() => true` only when every successful query in that client is
|
|
3314
|
+
meant for the browser. Never include tokens or server-only fields.
|
|
3315
|
+
|
|
3316
|
+
```ts
|
|
3317
|
+
// Create one QueryClient for this server request.
|
|
3318
|
+
const queryClient = createQueryClient({ now: () => Date.now() })
|
|
3319
|
+
await queryClient.prefetchQuery(["profile", user.id], loadProfile)
|
|
3320
|
+
const queryState = queryClient.dehydrate({
|
|
3321
|
+
// Nothing is sent unless this returns true: name what is safe for the visitor to read.
|
|
3322
|
+
shouldDehydrateQuery: ({ key }) => Array.isArray(key) && key[0] === "profile",
|
|
3323
|
+
})
|
|
3324
|
+
|
|
3325
|
+
// Return queryState through the route's normal loader-data serializer.
|
|
3326
|
+
// On the client, seed the app's client before query components mount.
|
|
3327
|
+
```
|
|
3328
|
+
|
|
3172
3329
|
### Invalidation
|
|
3173
3330
|
|
|
3174
3331
|
After a mutation, `useQueryClient().invalidateQueries(key)` marks matching entries
|
|
3175
3332
|
stale (by exact key or array **prefix**) and refetches the mounted ones - no manual cache
|
|
3176
3333
|
surgery.
|
|
3177
3334
|
|
|
3178
|
-
In an app with
|
|
3335
|
+
In an app with live refresh, a query can name the live keys its data
|
|
3179
3336
|
depends on: `useQuery(key, fn, { live: [`post:${id}`] })` refetches whenever
|
|
3180
3337
|
the server publishes one of them.
|
|
3181
3338
|
|
|
@@ -3185,7 +3342,7 @@ A cached query never answers for the next visitor. `identityChanged()` from
|
|
|
3185
3342
|
`@nifrajs/web/client` clears every query client in the page: mounted queries go
|
|
3186
3343
|
back to pending and refetch, the rest drop their data. A fetch still loading loads once more
|
|
3187
3344
|
for the new visitor before it settles. In an app with a
|
|
3188
|
-
|
|
3345
|
+
keepAlive route, the identity epoch cookie a sign-in
|
|
3189
3346
|
or sign-out response rotates does the same on the client's next read.
|
|
3190
3347
|
|
|
3191
3348
|
It's the same agnostic core under every adapter: the cache, dedup, and invalidation logic
|
|
@@ -3252,7 +3409,7 @@ Everything that lives in `@nifrajs/web` rather than the view layer works unchang
|
|
|
3252
3409
|
loaders, actions, ISR, SSG, head management, streaming. What you give up is hydration - these
|
|
3253
3410
|
are server-rendered documents, so set `export const hydrate = false` in the route's
|
|
3254
3411
|
`.backend.ts` half and reach for
|
|
3255
|
-
|
|
3412
|
+
islands where a page needs interactivity.
|
|
3256
3413
|
|
|
3257
3414
|
Worth it for the surfaces where HTML is the product: landing pages, listings, docs, comparison
|
|
3258
3415
|
tables. This documentation site renders that way.
|
|
@@ -3295,7 +3452,7 @@ export async function loader({ api }: Route.LoaderArgs) {
|
|
|
3295
3452
|
|
|
3296
3453
|
Component `<style scoped>` (Vue) and `<style>` (Svelte -
|
|
3297
3454
|
scoped by default) are compiled and scoped into the app stylesheet - no runtime, no FOUC - plus
|
|
3298
|
-
CSS Modules and global imports. See
|
|
3455
|
+
CSS Modules and global imports. See Dev & HMR → Styling.
|
|
3299
3456
|
`examples/routing-vue-sfc` is a full SSR + hydration + client-nav demo.
|
|
3300
3457
|
|
|
3301
3458
|
### Same features, every framework
|
|
@@ -3315,13 +3472,13 @@ progressive-enhancement forms (work with JS off).
|
|
|
3315
3472
|
- Optimistic UI, targeted revalidation, hover-prefetch, and scroll restoration.
|
|
3316
3473
|
|
|
3317
3474
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3475
|
+
Live refresh, keep-alive pages,
|
|
3476
|
+
server components, and
|
|
3477
|
+
partial prerendering.
|
|
3321
3478
|
|
|
3322
3479
|
-
|
|
3323
3480
|
True HMR in dev for all five (`@nifrajs/web/vite`) - see
|
|
3324
|
-
|
|
3481
|
+
Dev & HMR.
|
|
3325
3482
|
|
|
3326
3483
|
### One line changes
|
|
3327
3484
|
|
|
@@ -3385,7 +3542,7 @@ the client, with a warning in development.
|
|
|
3385
3542
|
Dev HMR works for all five adapters through `createViteDevServer` and the
|
|
3386
3543
|
framework's Vite plugin. React, Preact, and Vue preserve edited component state. Solid
|
|
3387
3544
|
and Svelte update live without a full page reload, and the edited component may remount. Full
|
|
3388
|
-
matrix in
|
|
3545
|
+
matrix in Dev & HMR.
|
|
3389
3546
|
|
|
3390
3547
|
### React Compiler
|
|
3391
3548
|
|
|
@@ -3811,7 +3968,7 @@ plugin, the principal is read from the **returned instance** - `auth.principal(r
|
|
|
3811
3968
|
(nullable) or `auth.requirePrincipal(req)` (throws `401`) - mirroring
|
|
3812
3969
|
`@nifrajs/auth` and `@nifrajs/better-auth`. It's verified once per request and
|
|
3813
3970
|
cached. For full session-based auth (OAuth, magic links, 2FA), see
|
|
3814
|
-
|
|
3971
|
+
Auth & sessions.
|
|
3815
3972
|
|
|
3816
3973
|
```ts
|
|
3817
3974
|
// doc-check: skip - fragment: `app`, `lookupUser`, and the `db` lookup are your application's.
|
|
@@ -3914,7 +4071,7 @@ app
|
|
|
3914
4071
|
`idempotency()` makes a retried unsafe request (same `Idempotency-Key` header)
|
|
3915
4072
|
replay the first response instead of re-running the side effect - no double-charge on a dropped
|
|
3916
4073
|
connection. It short-circuits before the handler; a concurrent retry gets a `409`. See
|
|
3917
|
-
|
|
4074
|
+
Security & hardening for the store contract, the production
|
|
3918
4075
|
guidance (shared store + DB constraint), and the `Set-Cookie` rule.
|
|
3919
4076
|
|
|
3920
4077
|
```ts
|
|
@@ -4165,7 +4322,7 @@ touches one key, so it runs on whichever node owns it.
|
|
|
4165
4322
|
The security set - `csrf` (signed double-submit + Origin/Referer), `jwt`,
|
|
4166
4323
|
`ipRestriction` (IPv4/IPv6 + CIDR, fails closed), and `bodyLimit`
|
|
4167
4324
|
(Content-Length cap before routing) - is documented with hardening guidance on
|
|
4168
|
-
|
|
4325
|
+
Security & hardening. All comparisons are constant-time and all
|
|
4169
4326
|
defaults fail closed.
|
|
4170
4327
|
|
|
4171
4328
|
### Error reporting
|
|
@@ -4192,7 +4349,7 @@ The pieces every production endpoint needs - a body-size cap for raw routes, rea
|
|
|
4192
4349
|
validation, constant-time webhook verification, and idempotent retries - ship as first-party
|
|
4193
4350
|
primitives. All are **edge-safe** (WebCrypto, no `node:crypto`) and run unchanged
|
|
4194
4351
|
on Bun, Node, Deno, and Workers. For how these defaults stack up against Hono, Fastify,
|
|
4195
|
-
Express, and Elysia, see
|
|
4352
|
+
Express, and Elysia, see security posture, compared.
|
|
4196
4353
|
|
|
4197
4354
|
### Responses that cannot leak more than they declare
|
|
4198
4355
|
|
|
@@ -4287,7 +4444,7 @@ export const app = server().use(
|
|
|
4287
4444
|
|
|
4288
4445
|
A `merge()`d server's routes are covered by a contract the parent installed
|
|
4289
4446
|
before the merge, as long as the route declares a response and its own server installed none.
|
|
4290
|
-
See
|
|
4447
|
+
See what a parent's use() covers.
|
|
4291
4448
|
|
|
4292
4449
|
The check itself is essentially free: with a compiled validator it measures in the
|
|
4293
4450
|
~100ns-per-response range, and a realistic middleware-carrying route benchmarks within noise
|
|
@@ -4640,7 +4797,7 @@ covering common image / A-V / archive types.
|
|
|
4640
4797
|
`signDownloadUrl` / `verifyDownloadUrl` mint short-TTL, tamper-evident
|
|
4641
4798
|
download links (HMAC-SHA256 over the path + expiry, constant-time verify). And
|
|
4642
4799
|
`stripImageMetadata` drops EXIF/GPS by re-encoding the image - through any
|
|
4643
|
-
|
|
4800
|
+
@nifrajs/image backend, with no dependency on it:
|
|
4644
4801
|
|
|
4645
4802
|
```ts
|
|
4646
4803
|
// doc-check: skip - fragment: continues the upload handler above (`result.bytes`).
|
|
@@ -4849,7 +5006,7 @@ nonce. For a strict `script-src` on web pages, give `createWebApp` a
|
|
|
4849
5006
|
`csp` from `createCspPolicy`: it allows the framework's constant
|
|
4850
5007
|
scripts by hash and adds a nonce only to a page that needs one, so every other page sends the
|
|
4851
5008
|
same header and stays cacheable under `withISR` or a CDN. See
|
|
4852
|
-
|
|
5009
|
+
A strict CSP that still caches.
|
|
4853
5010
|
|
|
4854
5011
|
### Route assurance - prove every route is guarded
|
|
4855
5012
|
|
|
@@ -5013,9 +5170,9 @@ rejected), SSR serialization that escapes every inline-script value,
|
|
|
5013
5170
|
`__Host-`/`__Secure-` cookie-prefix enforcement (a cookie whose
|
|
5014
5171
|
attributes violate its prefix contract fails at serialization rather than being silently
|
|
5015
5172
|
dropped by the browser), signed-cookie sessions + CSRF + route guards
|
|
5016
|
-
(
|
|
5017
|
-
limiter (
|
|
5018
|
-
(
|
|
5173
|
+
(@nifrajs/auth), bearer/apiKey auth + a shared-store rate
|
|
5174
|
+
limiter (@nifrajs/middleware), and a hardened image-resize endpoint
|
|
5175
|
+
(@nifrajs/image/server).
|
|
5019
5176
|
|
|
5020
5177
|
### Redacting logs
|
|
5021
5178
|
|
|
@@ -5359,8 +5516,8 @@ $ nifra levels
|
|
|
5359
5516
|
✓ L2 capability lockfile
|
|
5360
5517
|
```
|
|
5361
5518
|
|
|
5362
|
-
That is L2 on
|
|
5363
|
-
|
|
5519
|
+
That is L2 on the verification ladder. See also
|
|
5520
|
+
server functions, which are public POST endpoints and are
|
|
5364
5521
|
covered by exactly the same policy.
|
|
5365
5522
|
|
|
5366
5523
|
### Turning it down
|
|
@@ -5498,7 +5655,7 @@ as a session.
|
|
|
5498
5655
|
`identity` names the data keys that say who the visitor is: the user id, and any
|
|
5499
5656
|
key that changes what a page may show, such as an organization or a role. The cookie's tag,
|
|
5500
5657
|
in either mode, then changes only when one of them does, so
|
|
5501
|
-
|
|
5658
|
+
keep-alive keeps the pages it holds across a commit
|
|
5502
5659
|
that writes a cart or a preference. Unset, every key counts. A key left out that decides what
|
|
5503
5660
|
a page shows lets the next visitor of a browser see the pages kept for the previous one.
|
|
5504
5661
|
|
|
@@ -5534,12 +5691,12 @@ app.post("/api/login", async (c) => {
|
|
|
5534
5691
|
session.set("userId", String(username))
|
|
5535
5692
|
sessions.regenerate(session) // rotate the id on login (fixation defense)
|
|
5536
5693
|
await sessions.commit(c, session)
|
|
5537
|
-
return redirect("/")
|
|
5694
|
+
return redirect(rawHref("/")) // the Set-Cookie rides the redirect
|
|
5538
5695
|
})
|
|
5539
5696
|
|
|
5540
5697
|
app.post("/api/logout", async (c) => {
|
|
5541
5698
|
await sessions.destroy(c, await sessions.get(c))
|
|
5542
|
-
return redirect("/login")
|
|
5699
|
+
return redirect(rawHref("/login"))
|
|
5543
5700
|
})
|
|
5544
5701
|
```
|
|
5545
5702
|
|
|
@@ -5553,7 +5710,7 @@ path), and `requireSession` passes it, so guard a signed-in page with
|
|
|
5553
5710
|
`requireUser`. It is plain data, not
|
|
5554
5711
|
a `Response`: same bytes on the wire, on the lane an ordinary return takes. To guard
|
|
5555
5712
|
every page under a directory, run the same check in the `middleware` export of that
|
|
5556
|
-
directory's `_layout.backend.ts` - see
|
|
5713
|
+
directory's `_layout.backend.ts` - see Route middleware.
|
|
5557
5714
|
|
|
5558
5715
|
```ts
|
|
5559
5716
|
// routes/account.backend.ts - a protected route's loader reads the session and redirects when absent.
|
|
@@ -5684,7 +5841,7 @@ A page or a `frontend/` component that imported `backend/auth.ts` fails
|
|
|
5684
5841
|
the build with the import chain that reached it, so a secret cannot ride into the browser
|
|
5685
5842
|
bundle. A page that needs the user reads it from its loader data, which
|
|
5686
5843
|
`loaderOutput` narrows to the fields it declares - see
|
|
5687
|
-
|
|
5844
|
+
Project structure.
|
|
5688
5845
|
|
|
5689
5846
|
### CSRF
|
|
5690
5847
|
|
|
@@ -5759,9 +5916,9 @@ loader at a CDN and the runtime stays tiny. Or self-host: the optional
|
|
|
5759
5916
|
|
|
5760
5917
|
### The <Image> component
|
|
5761
5918
|
|
|
5762
|
-
`width` and `height` are **required** and validated
|
|
5763
|
-
`> 0
|
|
5764
|
-
(the CLS contract). It's `loading="lazy"` + `decoding="async"` by default;
|
|
5919
|
+
For string URLs, `width` and `height` are **required** and validated
|
|
5920
|
+
`> 0`. Imported metadata can supply them automatically. Dimensions reserve layout
|
|
5921
|
+
space so the page never shifts (the CLS contract). It's `loading="lazy"` + `decoding="async"` by default;
|
|
5765
5922
|
mark the LCP image with `priority` to get `eager` +
|
|
5766
5923
|
`fetchpriority="high"`. Extra DOM props (`className`, `style`,
|
|
5767
5924
|
`id`, `data-*`) pass straight through to the `<img>`.
|
|
@@ -5794,6 +5951,81 @@ The responsive `srcSet` is built from `widths` (default
|
|
|
5794
5951
|
the same URL (e.g. the identity loader), `srcSet` is omitted. The browser then picks
|
|
5795
5952
|
the right candidate for the device's pixel ratio and the `sizes` you declare.
|
|
5796
5953
|
|
|
5954
|
+
### Local image imports
|
|
5955
|
+
|
|
5956
|
+
Opt into `?image` imports to read PNG, JPEG, GIF and WebP dimensions at build time,
|
|
5957
|
+
including JPEG, PNG and WebP display orientation. The import is a browser-safe `StaticImageData`
|
|
5958
|
+
object; no filesystem code or codec ships to the browser. Ordinary string URLs are unchanged.
|
|
5959
|
+
|
|
5960
|
+
```ts
|
|
5961
|
+
// env.d.ts — enable the typed metadata import:
|
|
5962
|
+
/// <reference types="@nifrajs/image/imports" />
|
|
5963
|
+
|
|
5964
|
+
// routes/index.tsx (React; also supported by Preact, Solid, Vue and Svelte)
|
|
5965
|
+
import { Image } from "@nifrajs/web-react/image"
|
|
5966
|
+
import hero from "../shared/images/hero.jpg?image"
|
|
5967
|
+
|
|
5968
|
+
export default function Page() {
|
|
5969
|
+
return <Image src={hero} alt="Mountain lake" priority />
|
|
5970
|
+
// Optional width={600} infers height from the source aspect ratio.
|
|
5971
|
+
}
|
|
5972
|
+
```
|
|
5973
|
+
|
|
5974
|
+
```ts
|
|
5975
|
+
// backend/framework.ts — add these beside your existing framework plugins:
|
|
5976
|
+
import { imageBunPlugin } from "@nifrajs/image/plugins"
|
|
5977
|
+
|
|
5978
|
+
const images = { root: process.cwd() }
|
|
5979
|
+
export const clientPlugins = [imageBunPlugin(images)]
|
|
5980
|
+
export const serverPlugins = [imageBunPlugin(images)]
|
|
5981
|
+
|
|
5982
|
+
// For the Vite pipeline instead (including component mode):
|
|
5983
|
+
// import { imageVitePlugin } from "@nifrajs/image/plugins"
|
|
5984
|
+
// export const vitePlugins = [imageVitePlugin(images)]
|
|
5985
|
+
```
|
|
5986
|
+
|
|
5987
|
+
Keep the same image options in client and server builds. Preserve your framework's existing
|
|
5988
|
+
plugins when adding these. Metadata-only imports need no native dependency. Nifra emits the
|
|
5989
|
+
original bytes under `/assets/_images/` with content-hashed names, registers them in
|
|
5990
|
+
the build manifest, and serves them in development. Static builds deploy these files too;
|
|
5991
|
+
no image endpoint is needed. For standalone bundler use, emit the plugin's
|
|
5992
|
+
`nifraStaticAssets()` files yourself. A custom `publicPath` (a root-relative prefix
|
|
5993
|
+
or an absolute http(s) URL) must match your client build's asset prefix; a mismatch fails the build.
|
|
5994
|
+
|
|
5995
|
+
### Build-time responsive variants
|
|
5996
|
+
|
|
5997
|
+
Supply `widths` and an explicit `ImageBackend` to generate real responsive
|
|
5998
|
+
files at build time. This reuses the sharp, Bun.Image or WASM backend seam; sharp is an optional
|
|
5999
|
+
application dependency, not a Nifra runtime dependency. Both the processor and sharp path work
|
|
6000
|
+
on Node without Bun. Outputs support WebP (default), JPEG and PNG; widths never upscale the source.
|
|
6001
|
+
|
|
6002
|
+
```ts
|
|
6003
|
+
// doc-check: skip - install sharp and merge with your framework's existing plugins.
|
|
6004
|
+
import sharp from "sharp"
|
|
6005
|
+
import { Buffer } from "node:buffer"
|
|
6006
|
+
import { sharpImageBackend } from "@nifrajs/image/backends"
|
|
6007
|
+
import { imageBunPlugin } from "@nifrajs/image/plugins"
|
|
6008
|
+
|
|
6009
|
+
const images = {
|
|
6010
|
+
root: process.cwd(),
|
|
6011
|
+
widths: [320, 640, 1200],
|
|
6012
|
+
format: "webp" as const,
|
|
6013
|
+
quality: 80,
|
|
6014
|
+
backend: sharpImageBackend((bytes) => sharp(Buffer.from(bytes))),
|
|
6015
|
+
}
|
|
6016
|
+
export const clientPlugins = [imageBunPlugin(images)]
|
|
6017
|
+
export const serverPlugins = [imageBunPlugin(images)]
|
|
6018
|
+
// Vite: use imageVitePlugin(images) in vitePlugins instead.
|
|
6019
|
+
```
|
|
6020
|
+
|
|
6021
|
+
The component chooses only emitted variants; per-render `widths` filters available
|
|
6022
|
+
candidates rather than creating files. Build-time `quality` is baked in. An explicit
|
|
6023
|
+
CDN loader overrides the static variant selection. Defaults cap sources at 16 MiB and 40 million
|
|
6024
|
+
pixels; `maxSourceBytes` and `maxSourcePixels` are configurable. At most 32
|
|
6025
|
+
widths, each up to 8192 pixels, are accepted. Sources must remain inside `root`,
|
|
6026
|
+
including symlink targets. GIF, animated PNG and animated WebP imports are metadata-only; AVIF and SVG metadata
|
|
6027
|
+
imports are not supported.
|
|
6028
|
+
|
|
5797
6029
|
### Loaders
|
|
5798
6030
|
|
|
5799
6031
|
A loader is a pure `({ src, width, quality? }) => string` URL builder. Ship with
|
|
@@ -5946,7 +6178,7 @@ const url = signImageUrl("/_image", { src: "/private/a.jpg", width: 800 }, {
|
|
|
5946
6178
|
Signatures over `(src, w, q)` are **stable** (no expiry), so an SSR-rendered
|
|
5947
6179
|
`<Image>` srcset hydrates and caches identically. The secret makes a loader
|
|
5948
6180
|
config **server-only** - inject it from `env` in backend code, never a page or
|
|
5949
|
-
`frontend/` module (same discipline as a
|
|
6181
|
+
`frontend/` module (same discipline as a session secret). For time-limited links to
|
|
5950
6182
|
private images, `signImageUrl(…, { expiresIn })` adds an `&exp=` the
|
|
5951
6183
|
handler enforces.
|
|
5952
6184
|
|
|
@@ -6046,7 +6278,7 @@ permanent redirect - on full page loads, client navigations and form posts alike
|
|
|
6046
6278
|
// routes/[lang]/_layout.backend.ts - 404 unknown and draft locales, redirect /en/... to /...
|
|
6047
6279
|
import { defineLocales } from "@nifrajs/i18n"
|
|
6048
6280
|
import { defineI18nRouting } from "@nifrajs/i18n/routing"
|
|
6049
|
-
import { notFound, type RouteMiddleware, redirect } from "@nifrajs/web"
|
|
6281
|
+
import { notFound, type RouteMiddleware, rawHref, redirect } from "@nifrajs/web"
|
|
6050
6282
|
|
|
6051
6283
|
const urls = defineI18nRouting(
|
|
6052
6284
|
defineLocales({ default: "en", locales: { en: {}, hi: {}, gu: { draft: true } } }),
|
|
@@ -6056,7 +6288,7 @@ export const middleware: RouteMiddleware = (ctx) => {
|
|
|
6056
6288
|
const { pathname, search } = new URL(ctx.request.url)
|
|
6057
6289
|
const match = urls.matchSegment(ctx.params.lang, pathname + search)
|
|
6058
6290
|
if (match.kind === "not-found") notFound()
|
|
6059
|
-
if (match.kind === "redirect") return redirect(match.location, { status: 308 })
|
|
6291
|
+
if (match.kind === "redirect") return redirect(rawHref(match.location), { status: 308 })
|
|
6060
6292
|
return undefined
|
|
6061
6293
|
}
|
|
6062
6294
|
```
|
|
@@ -6094,7 +6326,7 @@ export function meta({ params, origin }: MetaArgs): Meta {
|
|
|
6094
6326
|
```
|
|
6095
6327
|
|
|
6096
6328
|
A page that exists in some languages only is declared once, with `pageLocales`
|
|
6097
|
-
(given the path without its locale prefix; it must be pure). Then
|
|
6329
|
+
(given the canonical path without its locale prefix; it must be pure). Then
|
|
6098
6330
|
`matchSegment` answers not-found for the other locales, `alternates`
|
|
6099
6331
|
lists only the page's own (none for a page in one locale), `localesOf(path)` names
|
|
6100
6332
|
them for a prerender's static paths, and `localizePathname(path, locale, { fallback: "default" })`
|
|
@@ -6102,6 +6334,84 @@ links a menu entry to the default locale's page where the page is missing. A
|
|
|
6102
6334
|
`pageLocales` that throws, or names a locale the registry does not declare, throws
|
|
6103
6335
|
rather than serving every locale.
|
|
6104
6336
|
|
|
6337
|
+
#### Explicit static translated pathnames
|
|
6338
|
+
|
|
6339
|
+
Optionally declare `pathnames`: canonical unprefixed static paths mapped to
|
|
6340
|
+
unprefixed locale spellings. Missing entries keep the canonical spelling; they do not make a
|
|
6341
|
+
page unavailable (`pageLocales` still owns that). Language switches, reverse
|
|
6342
|
+
lookup, canonical links, `hreflang` and `matchSegment` redirects all
|
|
6343
|
+
use the same table. With no table, existing prefix-only behavior is unchanged.
|
|
6344
|
+
|
|
6345
|
+
```ts
|
|
6346
|
+
// shared/i18n.ts - explicit STATIC pathname translations, not content or dynamic slug translation.
|
|
6347
|
+
import { defineLocales } from "@nifrajs/i18n"
|
|
6348
|
+
import { defineI18nRouting } from "@nifrajs/i18n/routing"
|
|
6349
|
+
|
|
6350
|
+
const locales = defineLocales({ default: "en", locales: { en: {}, fr: {}, de: {} } })
|
|
6351
|
+
export const urls = defineI18nRouting(locales, {
|
|
6352
|
+
pathnames: {
|
|
6353
|
+
"/about": { fr: "/a-propos", de: "/ueber-uns" },
|
|
6354
|
+
"/contact": { fr: "/contactez-nous" }, // Missing German name; availability is separate below.
|
|
6355
|
+
},
|
|
6356
|
+
// Always the canonical key, even when the incoming URL is /fr/contactez-nous.
|
|
6357
|
+
pageLocales: (path) => path === "/contact" ? ["en", "fr"] : undefined,
|
|
6358
|
+
})
|
|
6359
|
+
|
|
6360
|
+
urls.localizePathname("/about", "fr") // "/fr/a-propos"
|
|
6361
|
+
urls.localizePathname("/fr/a-propos", "de") // "/de/ueber-uns"
|
|
6362
|
+
urls.unlocalizePathname("/de/ueber-uns") // { locale: "de", pathname: "/about" }
|
|
6363
|
+
urls.alternates("/fr/a-propos").canonical // "/fr/a-propos"
|
|
6364
|
+
urls.staticPathnames() // ["/about", "/fr/a-propos", "/de/ueber-uns", "/contact", "/fr/contactez-nous"]
|
|
6365
|
+
```
|
|
6366
|
+
|
|
6367
|
+
`staticPathnames()` enumerates mapped public URLs only, in mapping declaration
|
|
6368
|
+
order then served-locale registry order, filtered by `pageLocales`. Feed explicit
|
|
6369
|
+
static entries to your prerender setup after wiring incoming routing; the prerender driver
|
|
6370
|
+
does not automatically enumerate catch-all routes. Unmapped pages are not discovered.
|
|
6371
|
+
Draft locales are never included. Unicode spellings such as `/紹介` are
|
|
6372
|
+
emitted URL-encoded and resolve from `new URL(request.url).pathname`. Reverse
|
|
6373
|
+
lookup returns a URL-encoded canonical pathname; `pageLocales` sees the declared
|
|
6374
|
+
canonical key. Query strings and trailing slashes survive translation, hashes too;
|
|
6375
|
+
SEO links and redirects omit the hash as before.
|
|
6376
|
+
|
|
6377
|
+
**Mappings do not create files or filesystem aliases.** A file named
|
|
6378
|
+
` about.tsx` alone will not serve `/fr/a-propos`. Supply matching
|
|
6379
|
+
routes yourself, or use a catch-all dispatcher that resolves
|
|
6380
|
+
` unlocalizePathname` to an explicit page registry, for example:
|
|
6381
|
+
|
|
6382
|
+
```ts
|
|
6383
|
+
// doc-check: skip - imports the app's own routing module and generated route types.
|
|
6384
|
+
// routes/[...path].backend.ts, paired with routes/[...path].tsx rendering props.data.page.
|
|
6385
|
+
// A root catch-all receives /about, /fr/a-propos and /de/ueber-uns; it needs at least one segment.
|
|
6386
|
+
import { notFound, redirect } from "@nifrajs/web"
|
|
6387
|
+
import { t } from "@nifrajs/schema"
|
|
6388
|
+
import { urls } from "../shared/i18n"
|
|
6389
|
+
import type { Route } from "./+types/[...path]"
|
|
6390
|
+
|
|
6391
|
+
const pages = new Map([["/about", "about"], ["/contact", "contact"]])
|
|
6392
|
+
export const loaderOutput = t.object({ page: t.string(), locale: t.string() })
|
|
6393
|
+
export function loader({ request }: Route.LoaderArgs) {
|
|
6394
|
+
const { pathname, search } = new URL(request.url)
|
|
6395
|
+
const match = urls.matchSegment(urls.getPathLocale(pathname), pathname + search)
|
|
6396
|
+
if (match.kind === "not-found") notFound()
|
|
6397
|
+
if (match.kind === "redirect") return redirect(match.location, { status: 308 })
|
|
6398
|
+
const canonical = urls.unlocalizePathname(pathname).pathname.replace(/\/$/, "") || "/"
|
|
6399
|
+
const page = pages.get(canonical)
|
|
6400
|
+
if (!page) notFound() // Includes unknown and draft-prefixed paths: never dispatch arbitrary input.
|
|
6401
|
+
return { page, locale: urls.localeOf(pathname) }
|
|
6402
|
+
}
|
|
6403
|
+
```
|
|
6404
|
+
|
|
6405
|
+
Keep a separate `routes/index.tsx` for the root; a catch-all needs at least one
|
|
6406
|
+
segment. Literal routes take precedence, so ensure they also use the same canonical checks
|
|
6407
|
+
when they overlap this dispatcher. Registering `i18n` below supplies locale
|
|
6408
|
+
metadata and prefix guards, not pathname rewrites. Dynamic slug maps, automatic filesystem
|
|
6409
|
+
aliases, automatic content translation and domain-based routing are outside this API.
|
|
6410
|
+
Invalid static paths (patterns, URL delimiters, dot segments or encoded separators), unknown
|
|
6411
|
+
locale keys, per-locale collisions including fallback paths, and translations shadowing
|
|
6412
|
+
another canonical key throw when the router is defined. Paths must not already carry a
|
|
6413
|
+
served locale prefix.
|
|
6414
|
+
|
|
6105
6415
|
### Register the routing once
|
|
6106
6416
|
|
|
6107
6417
|
Export the router as `i18n` from `backend/framework.ts` (re-export it from
|
|
@@ -6537,7 +6847,7 @@ export default { fetch: (req: Request, env: Env, ctx: ExecutionContext) =>
|
|
|
6537
6847
|
Export through `toFetchHandler` rather than handing the app out directly. Besides
|
|
6538
6848
|
`env` and `ctx.waitUntil`, it tells nifra the request came from the
|
|
6539
6849
|
platform's own HTTP parser, which lets the
|
|
6540
|
-
|
|
6850
|
+
bounded-body cap trust the declared
|
|
6541
6851
|
`Content-Length` as a real transport frame instead of re-counting every JSON body.
|
|
6542
6852
|
A bare `export default app` has no such signal and pays the extra pass unless you
|
|
6543
6853
|
set `server({ trustBodyFraming: true })`.
|
|
@@ -6661,7 +6971,7 @@ HTTP request, and `upgrade` reads what the guards derived. The origin check runs
|
|
|
6661
6971
|
first. A socket registered before a guard stays public, like an HTTP route there. A browser
|
|
6662
6972
|
cannot set a header on the handshake, so `authenticate()` can read a short-lived,
|
|
6663
6973
|
single-use ticket from `input.query` - see
|
|
6664
|
-
|
|
6974
|
+
Authentication runs first.
|
|
6665
6975
|
|
|
6666
6976
|
```ts
|
|
6667
6977
|
// doc-check: skip - illustrative: an existing auth guard and session lookup.
|
|
@@ -7012,7 +7322,7 @@ server()
|
|
|
7012
7322
|
|
|
7013
7323
|
## Nifra - Deployment
|
|
7014
7324
|
|
|
7015
|
-
> One Nifra app, one command per target - Bun, Node (Docker), Deno Deploy, Cloudflare Pages, Vercel Edge.
|
|
7325
|
+
> One Nifra app, one command per target - Bun, Node (Docker), Deno Deploy, Cloudflare Pages, Vercel Edge or Node.
|
|
7016
7326
|
|
|
7017
7327
|
`app.fetch(request)` is a pure Web-standard handler, so the same app runs
|
|
7018
7328
|
anywhere. Pick a runtime; the code doesn't change.
|
|
@@ -7082,7 +7392,7 @@ Cloudflare Pages
|
|
|
7082
7392
|
|
|
7083
7393
|
`wrangler.toml`
|
|
7084
7394
|
|
|
7085
|
-
Vercel Edge
|
|
7395
|
+
Vercel (Edge by default; Node opt-in)
|
|
7086
7396
|
|
|
7087
7397
|
`.vercel/output/`
|
|
7088
7398
|
|
|
@@ -7092,11 +7402,45 @@ none (Build Output API v3)
|
|
|
7092
7402
|
|
|
7093
7403
|
`nifra build --target static` also builds a site with no server: the prerendered
|
|
7094
7404
|
pages, the client bundle and `public/`, for any static host. See
|
|
7095
|
-
|
|
7405
|
+
SSG & ISR.
|
|
7096
7406
|
|
|
7097
7407
|
The Bun, Node and Deno entries serve the client bundle from disk next to themselves; on
|
|
7098
7408
|
Cloudflare and Vercel the platform serves it.
|
|
7099
7409
|
|
|
7410
|
+
#### Vercel: Edge or Node.js
|
|
7411
|
+
|
|
7412
|
+
Ordinary SSR keeps the existing Edge output for `nifra build --target vercel`.
|
|
7413
|
+
For Node built-ins and Node-compatible server libraries, keep the target and opt into Node
|
|
7414
|
+
in `nifra.config.ts` (there is no separate runtime CLI flag):
|
|
7415
|
+
|
|
7416
|
+
```ts
|
|
7417
|
+
// nifra.config.ts (alongside your adapter/clientModule exports)
|
|
7418
|
+
export const target = "vercel"
|
|
7419
|
+
export const vercelRuntime = "node" // "edge" or omitted preserves the Edge function
|
|
7420
|
+
|
|
7421
|
+
// Build and deploy from the project root:
|
|
7422
|
+
// bunx nifra build # or: bunx nifra build --target vercel
|
|
7423
|
+
// vercel deploy --prebuilt
|
|
7424
|
+
```
|
|
7425
|
+
|
|
7426
|
+
Both Bun and Vite production pipelines emit Build Output API v3 at
|
|
7427
|
+
`.vercel/output`: `static/` holds the client chunks and public files;
|
|
7428
|
+
`functions/index.func/` holds the SSR function. Node mode declares
|
|
7429
|
+
`nodejs22.x` and exports an HTTP handler without listening at import. It serves
|
|
7430
|
+
pages and the backend mounted with `apiPrefix`. Programmatic builds use
|
|
7431
|
+
`buildTarget("vercel", { ...options, vercelRuntime: "node" })`, or the same
|
|
7432
|
+
option on `buildTargetVite`. A different target or an unsupported runtime is
|
|
7433
|
+
refused before clearing the previous build; remove the selector when switching targets.
|
|
7434
|
+
|
|
7435
|
+
This is serverless Node, not the self-hosted `node` target: no Bun APIs, listening
|
|
7436
|
+
sockets, persistent in-process jobs or WebSocket server. Execution duration, streaming and
|
|
7437
|
+
filesystem availability remain subject to Vercel limits; native dependencies must be
|
|
7438
|
+
deploy-compatible. `selfHost` does not start a server here. Builds still require
|
|
7439
|
+
Bun. Static files are served first by Vercel, so host policy in the function cannot protect
|
|
7440
|
+
CDN files. The component pipeline retains its existing Vercel Node output and does not take
|
|
7441
|
+
this ordinary-SSR selector. The generated handler is tested locally under Node; this is not
|
|
7442
|
+
a claim of a live Vercel deployment test.
|
|
7443
|
+
|
|
7100
7444
|
The Bun, Node and Deno entries pass the socket peer as `c.clientIp`. Cloudflare
|
|
7101
7445
|
and Vercel expose no socket, so an edge build has no caller address unless
|
|
7102
7446
|
`nifra.config.ts` declares `export const clientIp = "platform"`: then
|
|
@@ -7195,7 +7539,7 @@ host-specific deploy step for you to fill in (Fly, a registry push, SSH, …).
|
|
|
7195
7539
|
### Bun (its home)
|
|
7196
7540
|
|
|
7197
7541
|
`app.listen(3000)` - the native Bun server. Bun is the runtime where Nifra measures
|
|
7198
|
-
fastest (see
|
|
7542
|
+
fastest (see benchmarks).
|
|
7199
7543
|
|
|
7200
7544
|
**Every core:** Bun is single-threaded per process - for multi-core boxes,
|
|
7201
7545
|
spawn one process per core, each binding the same port with
|
|
@@ -7204,8 +7548,8 @@ across them (Linux balances ~evenly). A supervisor that spawns + restarts worker
|
|
|
7204
7548
|
lines - see `examples/cluster.ts`. Anything shared across workers (rate limits,
|
|
7205
7549
|
sessions, pub/sub) needs a shared store, as in any multi-instance deploy. So do an ISR page
|
|
7206
7550
|
store (signed with one `storeSecret` in every process - see
|
|
7207
|
-
|
|
7208
|
-
|
|
7551
|
+
SSG & ISR) and
|
|
7552
|
+
live refresh (one Redis Streams bus for every process).
|
|
7209
7553
|
|
|
7210
7554
|
### Node & Deno
|
|
7211
7555
|
|
|
@@ -7319,8 +7663,9 @@ export default toFetchHandler(app)
|
|
|
7319
7663
|
```
|
|
7320
7664
|
|
|
7321
7665
|
Deploy: `wrangler pages deploy dist` (Pages) or `wrangler deploy`
|
|
7322
|
-
(Workers). The `vercel` target
|
|
7323
|
-
|
|
7666
|
+
(Workers). The `vercel` target defaults to an Edge Build Output API function
|
|
7667
|
+
under `.vercel/output`; [opt into Node.js](#vercel-node) for
|
|
7668
|
+
Node-compatible server dependencies.
|
|
7324
7669
|
|
|
7325
7670
|
## Nifra - CLI
|
|
7326
7671
|
|
|
@@ -7346,7 +7691,7 @@ nifra build --target cloudflare # also: node | deno | vercel | static; add --re
|
|
|
7346
7691
|
|
|
7347
7692
|
### The layout the CLI reads
|
|
7348
7693
|
|
|
7349
|
-
`nifra dev` runs the Bun-native
|
|
7694
|
+
`nifra dev` runs the Bun-native HMR dev server;
|
|
7350
7695
|
`nifra build` runs the production build (content-hashed client assets plus a
|
|
7351
7696
|
target-specific server); `nifra start` runs the default Bun output. The generated
|
|
7352
7697
|
server serves assets and SSR with matched-route chunks preloaded and route CSS linked in each
|
|
@@ -7360,7 +7705,7 @@ pipeline cannot run those, so that app gets Vite for dev and build alike, and sa
|
|
|
7360
7705
|
Vite-only app rather than dropping its transforms silently. Every `dev` and
|
|
7361
7706
|
`build` run prints which bundler it picked and why, and `nifra check`
|
|
7362
7707
|
answers the same question without starting a server - see
|
|
7363
|
-
|
|
7708
|
+
which pipeline runs, when for the full table.
|
|
7364
7709
|
|
|
7365
7710
|
```ts
|
|
7366
7711
|
my-app/
|
|
@@ -7383,7 +7728,7 @@ and `nifra check` reports it as NF-C038: run
|
|
|
7383
7728
|
`backend/app.ts` a composition root - merging modules, registering no routes of
|
|
7384
7729
|
its own - so each route's capability reach stays its own module's. What goes in each
|
|
7385
7730
|
zone, and what the builds refuse to cross, is on
|
|
7386
|
-
|
|
7731
|
+
Project structure.
|
|
7387
7732
|
|
|
7388
7733
|
### backend/framework.ts and nifra.config.ts
|
|
7389
7734
|
|
|
@@ -7415,6 +7760,17 @@ export const vitePlugins = [react()] // only if you want Vite's dev pip
|
|
|
7415
7760
|
// define = { __VUE_OPTIONS_API__: "true", ... } // Vue feature flags
|
|
7416
7761
|
```
|
|
7417
7762
|
|
|
7763
|
+
Ordinary `vercel` builds default to Edge. To opt into Node.js 22, export both
|
|
7764
|
+
`target = "vercel"` and `vercelRuntime = "node"` from
|
|
7765
|
+
`nifra.config.ts`, then run `nifra build` (or
|
|
7766
|
+
`nifra build --target vercel`) and `vercel deploy --prebuilt` from
|
|
7767
|
+
the project root. Both Bun and Vite builds write `.vercel/output` unless
|
|
7768
|
+
`--out` overrides it. Omit the selector or use `"edge"` to retain
|
|
7769
|
+
Edge; other values and use with a different target are refused before output is cleared.
|
|
7770
|
+
There is no separate runtime flag. Node functions support Node built-ins but not Bun APIs
|
|
7771
|
+
or a persistent server; the CLI/build still requires Bun. See
|
|
7772
|
+
runtime output and limitations.
|
|
7773
|
+
|
|
7418
7774
|
### Command reference
|
|
7419
7775
|
|
|
7420
7776
|
Every command `nifra --help` lists, by what it is for. Most take
|
|
@@ -7552,23 +7908,19 @@ What it does
|
|
|
7552
7908
|
|
|
7553
7909
|
`nifra types [--check]`
|
|
7554
7910
|
|
|
7555
|
-
Each route's `./+types` module under `.nifra/types`: params, schema-typed data, and `api` typed by `backend/app.ts`. `dev`, `build` and `check` refresh them too.
|
|
7911
|
+
Each route's `./+types` module under `.nifra/types`: params, schema-typed data, and `api` typed by `backend/app.ts`. It also writes `routes.d.ts`, the route table `href()` reads. `dev`, `build` and `check` refresh them too.
|
|
7556
7912
|
|
|
7557
7913
|
`nifra schemas [--write] [--check]`
|
|
7558
7914
|
|
|
7559
7915
|
Draft `loaderOutput` and `actionOutput` from each loader's and action's return type. `--write` adds the missing ones; it also lists returned fields a hand-written schema drops.
|
|
7560
7916
|
|
|
7561
|
-
`nifra sync-routes`
|
|
7562
|
-
|
|
7563
|
-
Regenerate `nifra-routes.d.ts` so `navigate({ to, search })` is typed by each route's search schema.
|
|
7564
|
-
|
|
7565
7917
|
`nifra sync-manifest`
|
|
7566
7918
|
|
|
7567
7919
|
Regenerate a committed `server-manifest.ts` from `routes/` without a full build.
|
|
7568
7920
|
|
|
7569
7921
|
`nifra scaffold hole <route> <name> [--shared] [--interactive] [--timeout <ms>] [--server]`
|
|
7570
7922
|
|
|
7571
|
-
|
|
7923
|
+
Add a hole to a partially prerendered route: its definition, `boundaries` entry and `Hole` in a JSX page, and a loader with its output schema in the backend half. A Vue or Svelte page gets the code to paste.
|
|
7572
7924
|
|
|
7573
7925
|
`nifra openapi [--format json | yaml] [--path <prefix>]`
|
|
7574
7926
|
|
|
@@ -7739,11 +8091,11 @@ install. Run from a CLI whose
|
|
|
7739
8091
|
copy cannot reflect the project's app, and says so in one line.
|
|
7740
8092
|
`nifra doctor` and
|
|
7741
8093
|
`nifra check` (NF-D002) point here when a workspace carries more than one version;
|
|
7742
|
-
see
|
|
8094
|
+
see mixed nifra versions. A
|
|
7743
8095
|
`file:` package whose dependencies this upgrade moves keeps its old ones in
|
|
7744
8096
|
`bun.lock`, where Bun never refreshes them; the plan lists each, and
|
|
7745
8097
|
`--write` drops those entries so the next `bun install` records them
|
|
7746
|
-
again (see
|
|
8098
|
+
again (see stale file: links).
|
|
7747
8099
|
|
|
7748
8100
|
A `link:` or `file:` dependency outside the root that installs its own
|
|
7749
8101
|
`@nifrajs/*` at another version stops the upgrade before anything is written: its
|
|
@@ -7773,7 +8125,7 @@ fixes for data loss ship as patches of it, so move to the latest with
|
|
|
7773
8125
|
|
|
7774
8126
|
`nifra build` defaults to a self-hosted Bun server. Use `--target node`,
|
|
7775
8127
|
`deno`, `cloudflare`, `vercel`, or `static` for another
|
|
7776
|
-
complete deploy shape (see
|
|
8128
|
+
complete deploy shape (see Deployment). Run non-Bun outputs with
|
|
7777
8129
|
the command printed by the build.
|
|
7778
8130
|
|
|
7779
8131
|
## Nifra - Coding agents
|
|
@@ -7783,7 +8135,7 @@ the command printed by the build.
|
|
|
7783
8135
|
Nifra ships an MCP server. It is not a documentation lookup bolted onto a framework: an agent
|
|
7784
8136
|
can read the project, learn the real API, run actual requests against the backend it just
|
|
7785
8137
|
edited, and finish with a report of what the change proved. The same typed capabilities can
|
|
7786
|
-
power the agent inside your product through
|
|
8138
|
+
power the agent inside your product through WebMCP and predictive UI
|
|
7787
8139
|
or stream into a product surface through AG-UI.
|
|
7788
8140
|
|
|
7789
8141
|
### One MCP, two ways to connect
|
|
@@ -8312,7 +8664,7 @@ Passing tests say the code does what its tests say. `nifra_levels` answers the
|
|
|
8312
8664
|
different question of what the project _holds_, as a cumulative ladder from a typed
|
|
8313
8665
|
contract (L0) to contract-derived invariant tests (L4). A scaffolded app starts at L1, and each
|
|
8314
8666
|
rung it has not reached reports the specific thing missing - so the ladder doubles as the list
|
|
8315
|
-
of what to do next. See
|
|
8667
|
+
of what to do next. See the verification ladder.
|
|
8316
8668
|
|
|
8317
8669
|
```bash
|
|
8318
8670
|
# The two an agent should gate on. Both exit non-zero on failure, so they work in CI unchanged.
|
|
@@ -8817,7 +9169,7 @@ export function Counter(props: { message: string }) {
|
|
|
8817
9169
|
|
|
8818
9170
|
`@nifrajs/devtools` is a plugin that streams what each request actually did - loader
|
|
8819
9171
|
traces, ISR status, route metadata - over a secured SSE endpoint, with an overlay to read it
|
|
8820
|
-
in the browser. In an app with
|
|
9172
|
+
in the browser. In an app with keep-alive routes, the overlay
|
|
8821
9173
|
also lists the pages kept hidden.
|
|
8822
9174
|
|
|
8823
9175
|
```ts
|
|
@@ -8840,12 +9192,12 @@ reads it through `nifra_errors`, `nifra_logs` and
|
|
|
8840
9192
|
`nifra_inspect`, and you can read it with `nifra errors` and
|
|
8841
9193
|
`nifra logs`. Pages get a small inline script that reports browser errors and
|
|
8842
9194
|
hydration mismatches back to the dev server; the dev server writes `.nifra/dev-server.json`
|
|
8843
|
-
so the tools can find it. See
|
|
9195
|
+
so the tools can find it. See coding agents.
|
|
8844
9196
|
|
|
8845
9197
|
When a page reports an error, a badge appears in its corner. It lists that page's errors with
|
|
8846
9198
|
their code, message, codeframe and fix, and a **Copy prompt** button per fix hands
|
|
8847
9199
|
a coding agent the error, one fix and the steps to check it worked (the
|
|
8848
|
-
|
|
9200
|
+
error codes page has the same prompts). The badge lives in a closed
|
|
8849
9201
|
shadow root, so the page's styles cannot reach it, and it loads under the page's CSP: by nonce,
|
|
8850
9202
|
by its exact URL, or through `'strict-dynamic'`. A page that never errors never
|
|
8851
9203
|
fetches it. Turn it off for one run with `nifra dev --no-indicator`, for every run
|
|
@@ -9374,7 +9726,7 @@ never reported.
|
|
|
9374
9726
|
This applies to every framework with module-global render state, not just React (Preact,
|
|
9375
9727
|
Vue, Solid, Svelte). Nifra dedupes the active adapter's runtime in build and dev; a
|
|
9376
9728
|
`file:`-linked package shipping its own copy is the thing to fix. See
|
|
9377
|
-
|
|
9729
|
+
Dev & HMR and the `file:`-linked-package note in
|
|
9378
9730
|
`AGENTS.md`.
|
|
9379
9731
|
|
|
9380
9732
|
###
|
|
@@ -9390,7 +9742,7 @@ That route's `data` infers `never` (Nifra can't see the shape). Return a
|
|
|
9390
9742
|
plain object and shape the response with `c.set` - reach for `c.json` /
|
|
9391
9743
|
`c.text` only for an error short-circuit (`throw` from a
|
|
9392
9744
|
`derive` / `beforeHandle`), not a route's happy path. See
|
|
9393
|
-
|
|
9745
|
+
API & typed client.
|
|
9394
9746
|
|
|
9395
9747
|
-
|
|
9396
9748
|
**A plugin widened the app's type.** A plugin that registers routes/hooks but whose return
|
|
@@ -9399,7 +9751,7 @@ makes `.use()` return `Server<any, any>` and the client loses your
|
|
|
9399
9751
|
registry. Build it with `defineRouterPlugin(name, …)` (the clearer-named
|
|
9400
9752
|
`defineIdentityPlugin`) so `.use()` returns your server unchanged and
|
|
9401
9753
|
routes added after it stay typed. See
|
|
9402
|
-
|
|
9754
|
+
Plugins → keep types with defineRouterPlugin.
|
|
9403
9755
|
|
|
9404
9756
|
`nifra check` flags the raw-`Response` case; the plugin case surfaces as a
|
|
9405
9757
|
`never` client at the call site.
|
|
@@ -9465,7 +9817,7 @@ export const app = server()
|
|
|
9465
9817
|
upfront**, and `implement(contract, handlers)` binds handlers to it. Nothing
|
|
9466
9818
|
grows a registry per call, so there is **no ceiling at all** - this is the path for
|
|
9467
9819
|
an API that will keep adding routes for years. Handlers stay checked against the contract exactly
|
|
9468
|
-
as inline routes are. See
|
|
9820
|
+
as inline routes are. See Contract-first.
|
|
9469
9821
|
|
|
9470
9822
|
```ts
|
|
9471
9823
|
import { defineContract, implement } from "@nifrajs/core/contract"
|
|
@@ -9542,7 +9894,7 @@ those, whatever the workspace installs, so two live-linked repositories that eac
|
|
|
9542
9894
|
version still run two), and the running CLI. When they disagree it names each version and
|
|
9543
9895
|
where it came from. It only reads files, and it never fails the run.
|
|
9544
9896
|
|
|
9545
|
-
The fix is
|
|
9897
|
+
The fix is `nifra upgrade <highest>`, not a
|
|
9546
9898
|
hand edit of the pins: it runs
|
|
9547
9899
|
every release's migration steps between your oldest pin and the target, then re-pins. Run it
|
|
9548
9900
|
without `--write` first to see each planned edit. It edits files under the
|
|
@@ -9572,7 +9924,7 @@ the manifests it is about to write and leaves `bun.lock` as it is.
|
|
|
9572
9924
|
|
|
9573
9925
|
Run `nifra check --json` as the done-gate - it surfaces the import-chain leaks,
|
|
9574
9926
|
typed-client drift, and raw-`Response`-from-a-route issues before you ship. The
|
|
9575
|
-
full machine-readable contract is at
|
|
9927
|
+
full machine-readable contract is at /llms-full.txt, and each
|
|
9576
9928
|
package ships a tight `LLM.md` contract card.
|
|
9577
9929
|
|
|
9578
9930
|
## Nifra - Backends & API (dev and prod)
|
|
@@ -10214,7 +10566,7 @@ A route is two files. The page (`x.tsx`) holds the view and its head:
|
|
|
10214
10566
|
`revalidate`. A `loader` runs on **GET** and feeds
|
|
10215
10567
|
`props.data`; an `action` runs on **POST** and feeds
|
|
10216
10568
|
`props.actionData`. A server-only export in the page file is a build error - see
|
|
10217
|
-
|
|
10569
|
+
Project structure.
|
|
10218
10570
|
|
|
10219
10571
|
```ts
|
|
10220
10572
|
// routes/users/[id].tsx - the page: it ships to the browser whole. Only `default` is required.
|
|
@@ -10271,7 +10623,7 @@ with `ctx.set.cookie()` / `ctx.set.deleteCookie()`.
|
|
|
10271
10623
|
```ts
|
|
10272
10624
|
// routes/account.backend.ts - response headers and cookies, from a loader or an action.
|
|
10273
10625
|
import { t } from "@nifrajs/schema"
|
|
10274
|
-
import { type LoaderContext, redirect } from "@nifrajs/web"
|
|
10626
|
+
import { type LoaderContext, rawHref, redirect } from "@nifrajs/web"
|
|
10275
10627
|
|
|
10276
10628
|
declare function signIn(email: string, password: string): Promise<{ token: string } | null>
|
|
10277
10629
|
|
|
@@ -10291,7 +10643,7 @@ export async function action(ctx: LoaderContext) {
|
|
|
10291
10643
|
if (session === null) return { error: "Wrong email or password" }
|
|
10292
10644
|
// HttpOnly; Secure; SameSite=Lax; Path=/ unless the options say otherwise.
|
|
10293
10645
|
ctx.set.cookie("session", session.token, { maxAge: 60 * 60 * 24 * 7 })
|
|
10294
|
-
throw redirect("/dashboard") // the cookie rides the redirect
|
|
10646
|
+
throw redirect(rawHref("/dashboard")) // the cookie rides the redirect
|
|
10295
10647
|
}
|
|
10296
10648
|
```
|
|
10297
10649
|
|
|
@@ -10675,7 +11027,7 @@ file that reaches it.
|
|
|
10675
11027
|
|
|
10676
11028
|
### Optional server components
|
|
10677
11029
|
|
|
10678
|
-
The optional
|
|
11030
|
+
The optional server-components pipeline supports
|
|
10679
11031
|
React, Preact, Vue, Svelte and Solid. Declare closed input/public-props schemas and authorization
|
|
10680
11032
|
in `*.component.server.ts(x)`, register owner instances and export a named
|
|
10681
11033
|
`componentPipeline` configuration. React uses native RSC/Flight; the other four
|
|
@@ -10848,8 +11200,8 @@ stable. The consumer still gets full end-to-end types both ways -
|
|
|
10848
11200
|
`.merge()` threads the router's routes into the host app's registry, and
|
|
10849
11201
|
`client(contract, url)` types every call from the same exported object.
|
|
10850
11202
|
|
|
10851
|
-
See
|
|
10852
|
-
two dev loops and the `--port` flag, and
|
|
11203
|
+
See SSG & ISR for prerendering, Dev & HMR for the
|
|
11204
|
+
two dev loops and the `--port` flag, and Loaders & actions for the
|
|
10853
11205
|
data layer in depth.
|
|
10854
11206
|
|
|
10855
11207
|
## Nifra - Control APIs (one schema, every client)
|
|
@@ -11310,7 +11662,7 @@ read the app import it, so everything the app does at module scope runs. A comma
|
|
|
11310
11662
|
reads what the app declares sets `NIFRA_REFLECT` to its own name first:
|
|
11311
11663
|
`check`, `routes`, `context`, `openapi`,
|
|
11312
11664
|
`contracts`, `capabilities`, `manifest`, `doctor`
|
|
11313
|
-
, `diff`, `sync-
|
|
11665
|
+
, `diff`, `sync-manifest`, and
|
|
11314
11666
|
`assure` without `--bundle`, `--strict`,
|
|
11315
11667
|
`--hydration`, `--interact` or `--out`. Commands that send the
|
|
11316
11668
|
app requests, such as `smoke`, `prove`, `levels` and the
|
|
@@ -11373,7 +11725,7 @@ nifra loads this app's copy for every importer:
|
|
|
11373
11725
|
|
|
11374
11726
|
Packages duplicated the same way are reported as one finding with one combined
|
|
11375
11727
|
`singleCopy` list. The preload this needs, and the version-skew case it cannot
|
|
11376
|
-
cover, are in
|
|
11728
|
+
cover, are in Troubleshooting.
|
|
11377
11729
|
|
|
11378
11730
|
## Nifra - Databases
|
|
11379
11731
|
|
|
@@ -11562,7 +11914,7 @@ CREATE POLICY tenant_isolation ON notes
|
|
|
11562
11914
|
|
|
11563
11915
|
The policy is the source of truth; `scoped()` just supplies the identity. Pair it with a
|
|
11564
11916
|
UUIDv7 `user_id` and an index on it. Connect `c.session.userId` from
|
|
11565
|
-
|
|
11917
|
+
@nifrajs/better-auth.
|
|
11566
11918
|
|
|
11567
11919
|
### Postgres (Raw Driver)
|
|
11568
11920
|
|
|
@@ -11635,13 +11987,13 @@ Cloudflare D1, Turso/libSQL
|
|
|
11635
11987
|
Neon serverless, Postgres over Hyperdrive, Prisma Accelerate
|
|
11636
11988
|
|
|
11637
11989
|
On Cloudflare, bindings like D1 are **typed** through `c.env` - see
|
|
11638
|
-
|
|
11990
|
+
Edge & bindings. For Workers MySQL/Postgres, Hyperdrive pools the
|
|
11639
11991
|
connection so a native driver works over the binding.
|
|
11640
11992
|
|
|
11641
11993
|
**Security:** always parameterize (`?` / driver placeholders or an ORM) - never
|
|
11642
11994
|
string-build SQL from request input. Nifra validates the request body/params at the boundary
|
|
11643
11995
|
(with `t` or any Standard Schema), so malformed input is rejected before your query
|
|
11644
|
-
runs. See
|
|
11996
|
+
runs. See Security.
|
|
11645
11997
|
|
|
11646
11998
|
Complete runnable references - a typed CRUD API you can diff your own against:
|
|
11647
11999
|
`examples/db-postgres` (Drizzle + Postgres, embedded PGlite - zero setup) and
|
|
@@ -11768,7 +12120,7 @@ patched the server HTML. In development the page reports it to the dev server as
|
|
|
11768
12120
|
`Date.now()`, `Math.random()`, locale formatting, reads of
|
|
11769
12121
|
`window` or `localStorage`, invalid HTML nesting. With happy-dom
|
|
11770
12122
|
installed in the project, `nifra_hydrate` reproduces it with a stable diagnostic.
|
|
11771
|
-
See
|
|
12123
|
+
See hydration.
|
|
11772
12124
|
|
|
11773
12125
|
#### NIFRA_SCHEMA_PARSE
|
|
11774
12126
|
|
|
@@ -11831,7 +12183,7 @@ them. Development reports each cookie name once.
|
|
|
11831
12183
|
carries the session, or in `keepAlive.ignoreCookies` if it does not. When the
|
|
11832
12184
|
session is a token in client storage, call `identityChanged()` from
|
|
11833
12185
|
`@nifrajs/web/client` at sign-in and sign-out. See
|
|
11834
|
-
|
|
12186
|
+
keep-alive and sign-in.
|
|
11835
12187
|
|
|
11836
12188
|
#### NIFRA_KEEPALIVE_DIRECT_CHILD_CSS
|
|
11837
12189
|
|
|
@@ -12122,7 +12474,7 @@ reads.
|
|
|
12122
12474
|
-
|
|
12123
12475
|
**CSP and browser:** React `Activity` hydration, inline styles under a
|
|
12124
12476
|
strict Content-Security-Policy, and WebKit's handling of streamed module scripts. Server-runtime differences are in
|
|
12125
|
-
|
|
12477
|
+
runtime differences.
|
|
12126
12478
|
|
|
12127
12479
|
### Version-sensitive advice
|
|
12128
12480
|
|
|
@@ -12208,7 +12560,7 @@ This is the part teams hand-roll incorrectly. `verifyWebhook` reads the raw body
|
|
|
12208
12560
|
bounded (DoS guard), verifies the signature in constant time, checks the timestamp
|
|
12209
12561
|
tolerance, and only then hands you the payload. Presets exist for Stripe and GitHub, and a
|
|
12210
12562
|
generic header/encoding form covers any other provider - including key rotation via an
|
|
12211
|
-
array of secrets. Details in
|
|
12563
|
+
array of secrets. Details in security.
|
|
12212
12564
|
|
|
12213
12565
|
#### 3. Processing exactly once
|
|
12214
12566
|
|
|
@@ -12228,7 +12580,7 @@ duplicate while the first is in flight.
|
|
|
12228
12580
|
|
|
12229
12581
|
### When to write a plugin
|
|
12230
12582
|
|
|
12231
|
-
Reach for
|
|
12583
|
+
Reach for a plugin only when a library should participate in
|
|
12232
12584
|
the framework itself: contribute typed context to every handler (`c.stripe`, a
|
|
12233
12585
|
session, a tenant), mount routes of its own, or hook the request lifecycle. That is
|
|
12234
12586
|
`definePlugin` - a few lines, typed end-to-end. For everything else, an import
|
|
@@ -12299,7 +12651,7 @@ Going back and then following a link drops the pages ahead of it, as the browser
|
|
|
12299
12651
|
those history entries.
|
|
12300
12652
|
|
|
12301
12653
|
-
|
|
12302
|
-
A page left with a
|
|
12654
|
+
A page left with a route open in a modal over
|
|
12303
12655
|
it is kept with the modal. Back to that entry shows the page and opens the modal over it
|
|
12304
12656
|
again.
|
|
12305
12657
|
|
|
@@ -12322,7 +12674,7 @@ them; reset in `onPageShow` what must start fresh.
|
|
|
12322
12674
|
|
|
12323
12675
|
-
|
|
12324
12676
|
Each kept page holds its DOM and its components' memory, at most three per tab. In
|
|
12325
|
-
development, the
|
|
12677
|
+
development, the devtools overlay lists them with their
|
|
12326
12678
|
path, how long each has been hidden and how many elements it renders.
|
|
12327
12679
|
|
|
12328
12680
|
### Fresh data
|
|
@@ -12333,14 +12685,14 @@ nothing below an unchanged value renders again, and form input in a list survive
|
|
|
12333
12685
|
`revalidate: false` to skip the reload; an action submitted while the page was
|
|
12334
12686
|
hidden still reloads it.
|
|
12335
12687
|
|
|
12336
|
-
A
|
|
12688
|
+
A partially prerendered page that is kept stops its
|
|
12337
12689
|
holes while it is hidden: a hole still loading is cancelled on the server, and a reload on its
|
|
12338
12690
|
way is dropped. When the page comes back each hole reloads in place, its old content marked
|
|
12339
12691
|
`aria-busy="true"` until the new arrives, with `revalidate: false` too.
|
|
12340
12692
|
An interactive hole keeps its state through it, in React as well, where
|
|
12341
12693
|
`<Activity>` cleans the page's effects up while it is hidden.
|
|
12342
12694
|
|
|
12343
|
-
With
|
|
12695
|
+
With live refresh, a hidden page is not watched. When it comes back,
|
|
12344
12696
|
what changed while it was hidden reloads, whatever `revalidate` says, and a grant
|
|
12345
12697
|
that expired in the meantime is loaded again.
|
|
12346
12698
|
|
|
@@ -12455,7 +12807,7 @@ export const clock = defineIsland((el) => {
|
|
|
12455
12807
|
})
|
|
12456
12808
|
```
|
|
12457
12809
|
|
|
12458
|
-
The
|
|
12810
|
+
The server components of a kept page stay mounted too.
|
|
12459
12811
|
With `bindComponentRouter` installed, navigation leaves them alone while the page
|
|
12460
12812
|
is hidden, and the reload of a page that comes back updates them.
|
|
12461
12813
|
|
|
@@ -12480,7 +12832,7 @@ main section { padding: 2rem; }
|
|
|
12480
12832
|
|
|
12481
12833
|
In development, the first time a kept page is shown the client reads the page's
|
|
12482
12834
|
same-origin stylesheets and reports each such selector once, as
|
|
12483
|
-
|
|
12835
|
+
NIFRA_KEEPALIVE_DIRECT_CHILD_CSS.
|
|
12484
12836
|
|
|
12485
12837
|
### Keep-alive and sign-in
|
|
12486
12838
|
|
|
@@ -12501,9 +12853,9 @@ A response that renews the same visitor's session keeps the epoch: a session coo
|
|
|
12501
12853
|
with a new lifetime, or an `@nifrajs/auth` session committed again with the same
|
|
12502
12854
|
data. Any change to an `@nifrajs/auth` session's data rotates it, in either mode,
|
|
12503
12855
|
so a sign-in or sign-out shows even when the session id stays the same. With
|
|
12504
|
-
|
|
12856
|
+
|
|
12505
12857
|
`identity`
|
|
12506
|
-
|
|
12858
|
+
|
|
12507
12859
|
set on `createSessions`, only a change to the keys it names rotates it, and a write
|
|
12508
12860
|
to a cart or a preference keeps it. An Auth.js session
|
|
12509
12861
|
read writes a new token every time; mounted through `@nifrajs/authjs`, it keeps
|
|
@@ -12527,7 +12879,7 @@ export const keepAlive = {
|
|
|
12527
12879
|
|
|
12528
12880
|
In development, an `HttpOnly` cookie that changes and is in neither list is
|
|
12529
12881
|
reported once, as
|
|
12530
|
-
|
|
12882
|
+
NIFRA_KEEPALIVE_IDENTITY_COOKIE. A flow
|
|
12531
12883
|
that changes who is signed in without changing a cookie rotates the epoch itself:
|
|
12532
12884
|
|
|
12533
12885
|
```ts
|
|
@@ -12627,7 +12979,7 @@ seed.
|
|
|
12627
12979
|
is your own name for a piece of data, such as `post:42`: a letter, then up to
|
|
12628
12980
|
127 of `A-Z a-z 0-9 . _ : / -`. A frame holds at most 64. A live load returns
|
|
12629
12981
|
an encrypted grant for its keys beside the data. A hole of a
|
|
12630
|
-
|
|
12982
|
+
partially prerendered page declares its own the
|
|
12631
12983
|
same way, and a change reloads that hole alone.
|
|
12632
12984
|
|
|
12633
12985
|
```ts
|
|
@@ -13316,7 +13668,7 @@ Past 5.0, 5.1 adds one change a frontend on another origin sees. A route with a
|
|
|
13316
13668
|
it. List that frontend's origin, or an identity provider's for a
|
|
13317
13669
|
`form_post` callback, in the `formOrigins` server option (an array of
|
|
13318
13670
|
exact origins or a function; `@nifrajs/edge` takes it too). JSON bodies are
|
|
13319
|
-
unchanged.
|
|
13671
|
+
unchanged. Security covers what the check leaves to
|
|
13320
13672
|
`csrf()`.
|
|
13321
13673
|
|
|
13322
13674
|
### 6. Run the release gates
|
|
@@ -13348,7 +13700,7 @@ rest needs a hand:
|
|
|
13348
13700
|
longer mounted. An islets `island("id", setup)` becomes
|
|
13349
13701
|
`bindIsland(setup)` passed to `mountIslands({ id })`, and a
|
|
13350
13702
|
nano signal is read by calling it (`count()`). See
|
|
13351
|
-
|
|
13703
|
+
Islands.
|
|
13352
13704
|
|
|
13353
13705
|
-
|
|
13354
13706
|
`withISR` over any store but `MemoryCacheStore` takes a
|
|
@@ -13464,8 +13816,8 @@ becomes a return.
|
|
|
13464
13816
|
1:1: `.get/.post` + a `t` schema, and an Eden-style typed client. You
|
|
13465
13817
|
gain Node / Deno / edge portability and an optional SSR frontend on five UI libraries.
|
|
13466
13818
|
|
|
13467
|
-
Then connect a database (
|
|
13468
|
-
full-stack, see
|
|
13819
|
+
Then connect a database (Database) and, if you're going
|
|
13820
|
+
full-stack, see Migrating a meta-framework.
|
|
13469
13821
|
|
|
13470
13822
|
## Nifra - Migrating from Next.js, Nuxt, SvelteKit & SolidStart
|
|
13471
13823
|
|
|
@@ -13522,26 +13874,26 @@ Nifra's client router - `Link` + hover/focus prefetch, scroll restoration
|
|
|
13522
13874
|
|
|
13523
13875
|
an action's `revalidate(paths, data, { tags })`, or
|
|
13524
13876
|
`revalidateEndpoint` for a webhook - see
|
|
13525
|
-
|
|
13877
|
+
SSG & ISR
|
|
13526
13878
|
|
|
13527
13879
|
Server Components · `"use client"`
|
|
13528
13880
|
|
|
13529
|
-
opt-in
|
|
13881
|
+
opt-in server components on all five adapters
|
|
13530
13882
|
|
|
13531
13883
|
Partial prerendering (Cache Components)
|
|
13532
13884
|
|
|
13533
13885
|
a `shellLoader` and holes - see
|
|
13534
|
-
|
|
13886
|
+
Partial prerendering
|
|
13535
13887
|
|
|
13536
13888
|
Intercepting routes (`(.)photo`)
|
|
13537
13889
|
|
|
13538
13890
|
a boundary with `{ intercept: "/photos/:id" }` - see
|
|
13539
|
-
|
|
13891
|
+
Opening a route in a modal
|
|
13540
13892
|
|
|
13541
13893
|
`keepalive` in `definePageMeta`
|
|
13542
13894
|
|
|
13543
13895
|
`export const keepAlive = true` - see
|
|
13544
|
-
|
|
13896
|
+
Keep-alive
|
|
13545
13897
|
|
|
13546
13898
|
### Data loading (Next.js → Nifra + React)
|
|
13547
13899
|
|
|
@@ -13596,14 +13948,14 @@ app.
|
|
|
13596
13948
|
**Much faster SSR** - the current dynamic-page snapshot reports Nifra at
|
|
13597
13949
|
15× the throughput of Next.js, 7.2× Nuxt, and
|
|
13598
13950
|
3.9× SvelteKit / 2.2× SolidStart, with a fraction
|
|
13599
|
-
of the client JavaScript. See
|
|
13951
|
+
of the client JavaScript. See benchmarks.
|
|
13600
13952
|
|
|
13601
13953
|
-
|
|
13602
13954
|
**End-to-end types with no codegen**, the same app on Bun / Node / Deno / the edge, and a
|
|
13603
|
-
backend you can also ship on its own. Start with
|
|
13955
|
+
backend you can also ship on its own. Start with Getting started.
|
|
13604
13956
|
|
|
13605
13957
|
Moving a backend (Express, Hono, Fastify, Elysia) instead? See
|
|
13606
|
-
|
|
13958
|
+
Migrating a backend.
|
|
13607
13959
|
|
|
13608
13960
|
## Nifra - Migrate route by route
|
|
13609
13961
|
|
|
@@ -13631,7 +13983,7 @@ app. Mount before the plugin when the legacy app keeps its own auth.
|
|
|
13631
13983
|
A mounted fetch handler carries HTTP only. A WebSocket upgrade under the mount reaches it as
|
|
13632
13984
|
an ordinary request and never becomes a socket, so keep the legacy app's sockets on its own
|
|
13633
13985
|
server until they move to `app.ws()` routes (see
|
|
13634
|
-
|
|
13986
|
+
WebSockets in a composed app).
|
|
13635
13987
|
|
|
13636
13988
|
```ts
|
|
13637
13989
|
import { Hono } from "hono"
|
|
@@ -13842,7 +14194,7 @@ No span carries a request body, a job payload, an event payload, a raw cache key
|
|
|
13842
14194
|
Without a tracer configured, the cache and the queue run the code they ran before: no clock
|
|
13843
14195
|
reads, no events, no extra frames.
|
|
13844
14196
|
|
|
13845
|
-
## Nifra - Partial prerendering
|
|
14197
|
+
## Nifra - Partial prerendering
|
|
13846
14198
|
|
|
13847
14199
|
> Serve a page's shared frame from a cached shell at once, then stream each per-visitor part as its own loader settles. Shared holes, server components in holes, a store shared by processes, Deno and Workers, eligibility rules, the no-JavaScript limit, proxies and connection limits.
|
|
13848
14200
|
|
|
@@ -13850,9 +14202,6 @@ Most of a product page is the same for everyone: the title, the description, the
|
|
|
13850
14202
|
partially prerendered route serves that part from a cached shell at once, then streams each
|
|
13851
14203
|
per-visitor part, a hole, into it as its own loader settles.
|
|
13852
14204
|
|
|
13853
|
-
[!WARNING] Experimental. It is enabled through `experimental.ppr`, and its API may
|
|
13854
|
-
change in any release.
|
|
13855
|
-
|
|
13856
14205
|
### Set it up
|
|
13857
14206
|
|
|
13858
14207
|
`compileShells` bundles each route's shell and refuses one whose emitted code
|
|
@@ -13890,9 +14239,7 @@ export const app = createWebApp({
|
|
|
13890
14239
|
csp: createCspPolicy({
|
|
13891
14240
|
header: ({ sources }) => `script-src 'self' ${sources}; object-src 'none'; base-uri 'none'`,
|
|
13892
14241
|
}),
|
|
13893
|
-
|
|
13894
|
-
ppr: partialPrerendering({ shellChecks, origin: "https://shop.example" }),
|
|
13895
|
-
},
|
|
14242
|
+
ppr: partialPrerendering({ shellChecks, origin: "https://shop.example" }),
|
|
13896
14243
|
})
|
|
13897
14244
|
```
|
|
13898
14245
|
|
|
@@ -14093,7 +14440,14 @@ largest timeout plus one second, at most 30 seconds.
|
|
|
14093
14440
|
|
|
14094
14441
|
-
|
|
14095
14442
|
A layout above it may have a loader only as a `gate`: the gate runs to redirect
|
|
14096
|
-
or refuse, and its data reaches no response.
|
|
14443
|
+
or refuse, and its data reaches no response.
|
|
14444
|
+
|
|
14445
|
+
-
|
|
14446
|
+
A route may declare an intercepting boundary (a
|
|
14447
|
+
modal route) beside its holes. It is not a hole and
|
|
14448
|
+
is not counted against the limit above. The shell carries it unresolved; a client
|
|
14449
|
+
navigation to its URL opens the target over the page, which stays mounted with its holes
|
|
14450
|
+
filled.
|
|
14097
14451
|
|
|
14098
14452
|
-
|
|
14099
14453
|
`shellVariations` lists closed sets of query values that each select their own
|
|
@@ -14593,7 +14947,7 @@ its `compatibility_date`.
|
|
|
14593
14947
|
|
|
14594
14948
|
The browser side has the same property: the behavior belongs to React or the
|
|
14595
14949
|
browser, and Nifra only sits on top of it. Those entries live in the
|
|
14596
|
-
|
|
14950
|
+
frontend gotchas catalog (`nifra frontend`),
|
|
14597
14951
|
next to the per-framework reactivity cases:
|
|
14598
14952
|
|
|
14599
14953
|
-
|
|
@@ -14621,7 +14975,7 @@ each runtime, record the versions, and keep the cause to what the runtime does.
|
|
|
14621
14975
|
Which hardening each framework actually ships. A dimension-by-dimension read of Nifra's
|
|
14622
14976
|
security defaults against the **current releases** of Hono, Fastify, Express, and Elysia -
|
|
14623
14977
|
what is on by default, what is opt-in, and what is left to a third-party package. For how each
|
|
14624
|
-
Nifra primitive works, see
|
|
14978
|
+
Nifra primitive works, see Security & hardening.
|
|
14625
14979
|
|
|
14626
14980
|
### The honest verdict
|
|
14627
14981
|
|
|
@@ -15028,8 +15382,8 @@ claim; Express's ubiquity means every hire already knows it. Nifra's argument is
|
|
|
15028
15382
|
narrower and honest: it makes the dangerous configurations _unrepresentable_, ships the
|
|
15029
15383
|
hardening primitives first-party, and lets `nifra assure` prove in CI that every
|
|
15030
15384
|
route is guarded. For the full capability and throughput comparison, see
|
|
15031
|
-
|
|
15032
|
-
|
|
15385
|
+
vs other frameworks and the
|
|
15386
|
+
per-framework pages.
|
|
15033
15387
|
|
|
15034
15388
|
## Nifra - Security testing
|
|
15035
15389
|
|
|
@@ -15138,9 +15492,8 @@ Reaches the browser
|
|
|
15138
15492
|
`routes/x.tsx` (`.svelte`, `.vue`, `.mdx`)
|
|
15139
15493
|
|
|
15140
15494
|
a page: the component, `meta`,
|
|
15141
|
-
|
|
15495
|
+
|
|
15142
15496
|
`keepAlive`
|
|
15143
|
-
](/docs/keep-alive)
|
|
15144
15497
|
|
|
15145
15498
|
yes
|
|
15146
15499
|
|
|
@@ -15149,7 +15502,7 @@ yes
|
|
|
15149
15502
|
that page's `loader`, `action`, `loaderOutput`,
|
|
15150
15503
|
`actionOutput`, `hydrate`, `revalidate`,
|
|
15151
15504
|
`shellLoader` and `boundaryLoaders` (a
|
|
15152
|
-
|
|
15505
|
+
partially prerendered page),
|
|
15153
15506
|
`middleware` (in `_layout.backend.ts`)
|
|
15154
15507
|
|
|
15155
15508
|
never
|
|
@@ -15262,7 +15615,7 @@ Those commands, the contract lock and the route lints see only what
|
|
|
15262
15615
|
same app from `backend/app.ts` built with stand-in dependencies, so every operation
|
|
15263
15616
|
is visible without a database or secrets; `nifra check` names an implemented
|
|
15264
15617
|
operation it does not serve (NF-C039). See
|
|
15265
|
-
|
|
15618
|
+
the stand-in entry.
|
|
15266
15619
|
|
|
15267
15620
|
### A route is two files
|
|
15268
15621
|
|
|
@@ -15311,7 +15664,9 @@ and `Route.ComponentProps` types `data` as exactly what
|
|
|
15311
15664
|
`loaderOutput` lets through. `nifra dev`, `nifra build`,
|
|
15312
15665
|
`nifra check` and `nifra types` write these files under
|
|
15313
15666
|
`.nifra/types`; the app's `tsconfig.json` resolves them with
|
|
15314
|
-
`"rootDirs": [".", "./.nifra/types"]`.
|
|
15667
|
+
`"rootDirs": [".", "./.nifra/types"]`. The same directory holds
|
|
15668
|
+
`routes.d.ts`, one entry per URL pattern with its params and search output, and
|
|
15669
|
+
every generated `./+types` module loads it.
|
|
15315
15670
|
|
|
15316
15671
|
### What may import what
|
|
15317
15672
|
|
|
@@ -15455,9 +15810,9 @@ Whether it catches _undeclared extra_ fields depends on your validator, not on n
|
|
|
15455
15810
|
strict schema (`@nifrajs/schema`'s `t.object`) reports them and the
|
|
15456
15811
|
test fails, while a stripping one (Zod, Valibot) accepts them silently. To catch extras
|
|
15457
15812
|
regardless, or to stop them reaching the wire in production, use
|
|
15458
|
-
|
|
15813
|
+
|
|
15459
15814
|
`responseContract`
|
|
15460
|
-
|
|
15815
|
+
|
|
15461
15816
|
.
|
|
15462
15817
|
|
|
15463
15818
|
### Opaque schemas stay validator-neutral
|
|
@@ -15732,7 +16087,7 @@ more than one service, declare it with `defineContract` and connect handlers wit
|
|
|
15732
16087
|
`implement`. That keeps the contract type available without importing a server
|
|
15733
16088
|
implementation into the client.
|
|
15734
16089
|
|
|
15735
|
-
See
|
|
16090
|
+
See Framework contract for the decoupled form and its scaling
|
|
15736
16091
|
guidance.
|
|
15737
16092
|
|
|
15738
16093
|
The tooling reads the backend `backend/app.ts` exports. An app that
|
|
@@ -15800,7 +16155,7 @@ would refuse: backend code in a page, or a server package in browser code.
|
|
|
15800
16155
|
-
|
|
15801
16156
|
Validation only covers what you put in a schema. A raw-body, file-upload, or
|
|
15802
16157
|
bring-your-own-validation route reads the body directly - cap and validate those yourself
|
|
15803
|
-
(see
|
|
16158
|
+
(see Security's `c.boundedBody`).
|
|
15804
16159
|
|
|
15805
16160
|
-
|
|
15806
16161
|
The typed client infers from the server _type_, so it needs an
|
|
@@ -20108,7 +20463,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
20108
20463
|
|
|
20109
20464
|
## @nifrajs/ts-plugin
|
|
20110
20465
|
|
|
20111
|
-
A TypeScript language-service plugin for [nifra](https://github.com/nifrajs/nifra). It adds go-to-definition on route-path string literals: put your cursor on `"/orders"` in `
|
|
20466
|
+
A TypeScript language-service plugin for [nifra](https://github.com/nifrajs/nifra). It adds go-to-definition on route-path string literals: put your cursor on `"/orders"` in `href({ to: "/orders" })`, `rawHref("/orders")`, or `<a href="/orders">`, and jump straight to the `routes/` file that serves it. A route-table pattern such as `"/users/:id"` resolves to its file too.
|
|
20112
20467
|
|
|
20113
20468
|
The routing rules are nifra's own - it discovers routes with `@nifrajs/web` and matches them with `@nifrajs/core`'s pattern matcher - so a path resolves to exactly the file it would serve at runtime, dynamic segments included (`/users/42` → `routes/users/[id].tsx`).
|
|
20114
20469
|
|
|
@@ -20194,8 +20549,8 @@ One package, the same on React, Preact, Vue, Solid and Svelte (pick the renderer
|
|
|
20194
20549
|
- Streaming SSR with `defer()`, SSG, and ISR with tag purges - [rendering](https://nifra.dev/docs/rendering).
|
|
20195
20550
|
- [Live refresh](https://nifra.dev/docs/live) (`@nifrajs/web/live`, `/live-client`, `/live-redis`):
|
|
20196
20551
|
loaders declare keys, a publish reloads only what read them.
|
|
20197
|
-
- [Partial prerendering](https://nifra.dev/docs/partial-prerendering) (`@nifrajs/web/ppr
|
|
20198
|
-
|
|
20552
|
+
- [Partial prerendering](https://nifra.dev/docs/partial-prerendering) (`@nifrajs/web/ppr`): a cached
|
|
20553
|
+
shell, with per-visitor holes streamed in.
|
|
20199
20554
|
- [Keep-alive](https://nifra.dev/docs/keep-alive) pages, a query cache, optimistic fetchers, and
|
|
20200
20555
|
[islands](https://nifra.dev/docs/islands) (`@nifrajs/web/islands`) for pages with no framework runtime.
|
|
20201
20556
|
- Optional [server components](https://nifra.dev/docs/server-components) on all five adapters:
|
|
@@ -20774,7 +21129,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
20774
21129
|
|
|
20775
21130
|
## @nifrajs/image
|
|
20776
21131
|
|
|
20777
|
-
`CloudflareLoaderOptions`, `HtmlImageAttrs`, `ImageFormat`, `ImageInfo`, `ImageLoader`, `ImageProps`, `OgImageOptions`, `OgImageRasterized`, `OgImageRasterizer`, `PngRenderer`, `ResolvedImage`, `ResvgConstructor`, `ResvgRenderer`, `SelfHostedLoaderOptions`, `SignImageUrlOptions`, `cloudflareLoader`, `createPngRasterizer`, `createResvgRasterizer`, `identityLoader`, `imageDimensions`, `ogImageResponse`, `readImageDimensions`, `renderOgImage`, `resolveImage`, `selfHostedLoader`, `signImageUrl`, `toHtmlAttrs`
|
|
21132
|
+
`CloudflareLoaderOptions`, `HtmlImageAttrs`, `ImageFormat`, `ImageInfo`, `ImageInputProps`, `ImageLoader`, `ImagePresentationProps`, `ImageProps`, `OgImageOptions`, `OgImageRasterized`, `OgImageRasterizer`, `PngRenderer`, `ResolvedImage`, `ResvgConstructor`, `ResvgRenderer`, `SelfHostedLoaderOptions`, `SignImageUrlOptions`, `StaticImageData`, `StaticImageProps`, `StaticImageVariant`, `cloudflareLoader`, `createPngRasterizer`, `createResvgRasterizer`, `identityLoader`, `imageDimensions`, `ogImageResponse`, `readImageDimensions`, `renderOgImage`, `resolveImage`, `selfHostedLoader`, `signImageUrl`, `toHtmlAttrs`
|
|
20778
21133
|
|
|
20779
21134
|
## @nifrajs/island-trigger
|
|
20780
21135
|
|
|
@@ -20846,7 +21201,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
20846
21201
|
|
|
20847
21202
|
## @nifrajs/web
|
|
20848
21203
|
|
|
20849
|
-
`ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryLoaderEntry`, `BoundaryLoadersOf`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `BuildAssetSet`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `DataText`, `Deferred`, `DehydratedState`, `DocumentParts`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `
|
|
21204
|
+
`ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryLoaderEntry`, `BoundaryLoadersOf`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `BuildAssetSet`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `DataText`, `Deferred`, `DehydrateOptions`, `DehydratedQueryInfo`, `DehydratedState`, `DocumentParts`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `GenerateServerManifestOptions`, `GetStaticPaths`, `HANDOVER_ID`, `HostPolicy`, `HostPolicyOptions`, `HostPolicyRule`, `Href`, `HrefOptions`, `HtmlSanitizer`, `IDLE_BLOCKER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `ISRQuery`, `ISRStoreOp`, `ISR_REVALIDATE_HEADER`, `ISR_REVALIDATE_TAGS_HEADER`, `ISR_STATUS_HEADER`, `IdentityEpochContext`, `InertScriptType`, `InfiniteData`, `InfiniteQueryHandle`, `InfiniteQueryOptions`, `InterceptBoundary`, `Intercepted`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `KeepAliveOptions`, `KeepAliveServerOptions`, `KeptPage`, `LAYOUT_DATA_GLOBAL`, `LOCALES_GLOBAL`, `LayoutEntry`, `LinkDescriptor`, `LiveClientEntry`, `Loader`, `LoaderContext`, `LoaderResponseControls`, `LoadingEntry`, `Manifest`, `MatchChain`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `MemoryStaticBoundaryCache`, `Meta`, `MetaArgs`, `MetaDescriptor`, `MetaInput`, `MiddlewareOutcome`, `MountRouterOptions`, `MutationCallbacks`, `MutationCancelledError`, `MutationContext`, `MutationHandle`, `MutationState`, `MutationStatus`, `NAV_FROM_HEADER`, `NavigateFunction`, `NavigateOptions`, `NonceContext`, `NonceGenerator`, `NonceHeader`, `NonceHeaderContext`, `NonceResolver`, `NotFoundEntry`, `NotFoundScope`, `OpenGraphInput`, `PREFETCH_HEADER`, `PRE_HYDRATION_GUARD`, `PageLocale`, `PageLocales`, `PendingBoundary`, `PrefetchMode`, `PrerenderedPageReaderOptions`, `PrerenderedPages`, `PreviewEndpointOptions`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryOptions`, `QueryState`, `QueryStatus`, `REDIRECT_HEADER`, `RETAIN_HEADER`, `REVALIDATE_HEADER`, `ROOT_ATTRIBUTE`, `ROUTE_GLOBAL`, `RedirectOptions`, `RenderAdapter`, `RenderAdapterConformanceError`, `RenderAdapterConformanceFixture`, `RenderAssemblyCache`, `RenderPageInput`, `RenderPageOptions`, `RenderProps`, `RenderStreamOptions`, `RenderedPage`, `RevalidateEndpointOptions`, `RevalidateOptions`, `RevalidateResult`, `RevalidateTags`, `RevalidateTagsInput`, `RouteEntry`, `RouteMatch`, `RouteMiddleware`, `RouteModule`, `RoutePattern`, `RouteTable`, `RouterState`, `SERVER_FN_MODULE`, `STATUS_HEADER`, `SanitizedHtml`, `ScriptDescriptor`, `SearchOf`, `SharedBoundary`, `SharedHoleCtx`, `ShellCtx`, `ShouldRevalidate`, `ShouldRevalidateArgs`, `SsrModuleLoader`, `StaticBoundary`, `StaticBoundaryCache`, `StaticBoundaryImportEdge`, `StaticBoundaryRoot`, `StaticCtx`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `StatusPageOptions`, `Submission`, `SubmitOptions`, `TrustedHtml`, `UIMatch`, `UnsafeScriptDescriptor`, `WebAppI18n`, `assertCssLoadingCompatible`, `assertRenderAdapterConformance`, `assertStaticBoundaryImports`, `boundaryDescriptors`, `boundaryModeKey`, `buildManifest`, `canonical`, `closeBoundary`, `createClientRouter`, `createCspPolicy`, `createHostPolicy`, `createMatcher`, `createMutation`, `createNonceResolver`, `createQueryClient`, `createWebApp`, `defer`, `disableDraft`, `enableDraft`, `enumerateStaticRoutes`, `filePathToPattern`, `filePathToPatterns`, `fontFace`, `fontPreload`, `generateClientEntry`, `generateServerManifest`, `getBrowserNavigate`, `gone`, `hashQueryKey`, `href`, `isCacheablePage`, `isDraftEnabled`, `isHostPolicy`, `jsonLd`, `localeOfProps`, `mergeHeads`, `nifraScriptHashes`, `normalizeCssLoading`, `notFound`, `openGraph`, `pageLocaleIn`, `prerenderedPageReader`, `previewEndpoint`, `rawHref`, `redirect`, `registerBlocker`, `renderPage`, `renderPageResult`, `resolveChainMeta`, `resolveDynamicBoundaries`, `resolveMeta`, `resolvePublicPath`, `resolveStaticBoundaries`, `revalidate`, `revalidateEndpoint`, `rotateIdentityEpoch`, `sanitizeHtml`, `sanitizedHtml`, `searchOf`, `searchOfChain`, `serializeData`, `serializeSearch`, `setBlockerController`, `setBrowserNavigate`, `setSsrModuleLoader`, `ssrModuleLoader`, `startDynamicBoundaries`, `statusPage`, `trustHtml`, `unsafeInlineScript`, `webProjectEvidence`, `withISR`
|
|
20850
21205
|
|
|
20851
21206
|
## @nifrajs/web-preact
|
|
20852
21207
|
|