@rsc-kit/mcp 0.41.0 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/recipes.js +18 -2
- package/dist/recipes.js.map +1 -1
- package/guides/admin-plugins.md +206 -6
- package/guides/api-routes.md +159 -215
- package/guides/authorization.md +103 -114
- package/guides/backend-answered-pages.md +301 -252
- package/guides/bap-vs-inertia.md +67 -25
- package/guides/blueprints.md +300 -169
- package/guides/bun.md +42 -25
- package/guides/caching.md +46 -49
- package/guides/coming-from-inertia.md +2 -2
- package/guides/commands.md +251 -200
- package/guides/connection.md +50 -54
- package/guides/content-security-policy.md +133 -84
- package/guides/domains.md +190 -149
- package/guides/edge-caching.md +242 -268
- package/guides/emails.md +96 -45
- package/guides/errors.md +116 -137
- package/guides/feature-flags.md +100 -30
- package/guides/file-uploads.md +101 -26
- package/guides/fonts.md +139 -110
- package/guides/forms.md +520 -542
- package/guides/images.md +87 -28
- package/guides/index.json +13 -33
- package/guides/instrumentation.md +134 -95
- package/guides/isr.md +3 -3
- package/guides/live-data-in-production.md +695 -0
- package/guides/live-data.md +170 -839
- package/guides/mcp.md +83 -59
- package/guides/metadata.md +124 -179
- package/guides/navigation.md +118 -147
- package/guides/no-javascript.md +49 -57
- package/guides/offline.md +118 -153
- package/guides/openapi.md +100 -35
- package/guides/pages.md +160 -50
- package/guides/ppr.md +178 -256
- package/guides/pwa.md +270 -216
- package/guides/queries.md +171 -300
- package/guides/react-compiler.md +90 -50
- package/guides/redirects.md +141 -177
- package/guides/response-headers.md +76 -74
- package/guides/route-interception.md +112 -111
- package/guides/routing.md +216 -322
- package/guides/sections.md +63 -66
- package/guides/seo-files.md +127 -65
- package/guides/server-actions.md +285 -357
- package/guides/static-generation.md +131 -199
- package/guides/testing.md +269 -147
- package/guides/third-party-scripts.md +94 -47
- package/guides/typed-routes.md +115 -113
- package/guides/url-validation.md +113 -61
- package/guides/validation.md +53 -62
- package/guides/view-transitions.md +159 -132
- package/guides/where-it-runs.md +226 -162
- package/package.json +2 -2
- package/guides/admin.md +0 -520
- package/guides/deployment.md +0 -598
- package/guides/go.md +0 -539
- package/guides/laravel.md +0 -787
- package/guides/your-own-backend.md +0 -602
package/guides/where-it-runs.md
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
> A host is a Nitro preset, not a server you write.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
choosing where an app runs is choosing a preset.
|
|
5
|
+
[Nitro](https://nitro.build) builds the server around your route tree, so
|
|
6
|
+
choosing where an app runs is choosing a preset. There is no server file to
|
|
7
|
+
write:
|
|
9
8
|
|
|
10
9
|
```ts title="vite.config.ts"
|
|
11
10
|
import { defineConfig } from 'vite';
|
|
@@ -23,13 +22,11 @@ export default defineConfig({
|
|
|
23
22
|
```
|
|
24
23
|
|
|
25
24
|
`bun create rsc-kit@latest my-app` writes that for you. Changing where it deploys is
|
|
26
|
-
changing the one string.
|
|
25
|
+
changing the one string. [Deploying](/hosts/deployment/) covers shipping it.
|
|
27
26
|
|
|
28
|
-
##
|
|
27
|
+
## Choosing a preset
|
|
29
28
|
|
|
30
|
-
`rsc-kit` asks about three, because those are the ones it can check for you
|
|
31
|
-
Nitro carries [many more](https://nitro.build/deploy) and they need nothing from
|
|
32
|
-
this package — a preset is a string, not an integration.
|
|
29
|
+
`rsc-kit` asks about three, because those are the ones it can check for you:
|
|
33
30
|
|
|
34
31
|
| `--host` | preset | what you get |
|
|
35
32
|
| --- | --- | --- |
|
|
@@ -37,25 +34,18 @@ this package — a preset is a string, not an integration.
|
|
|
37
34
|
| `node` | `node` | `.output/server/index.mjs`, run with `node` |
|
|
38
35
|
| `worker` | `cloudflare_module` | a Worker, plus the `wrangler.json` and `_headers` Nitro generates |
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
deploy, which is what Pages was for.
|
|
44
|
-
|
|
45
|
-
Everything else — Vercel, Netlify, Azure, Deno, AWS Amplify — is the same
|
|
46
|
-
change:
|
|
37
|
+
Nitro carries [many more](https://nitro.build/deploy), and they need nothing from
|
|
38
|
+
this package — a preset is a string, not an integration. Vercel, Netlify,
|
|
39
|
+
Azure, Deno and AWS Amplify are all the same change:
|
|
47
40
|
|
|
48
41
|
```ts
|
|
49
42
|
nitro({ preset: 'vercel', serveStatic: 'inline' })
|
|
50
43
|
```
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
platform's request limits cut streams (they reconnect and catch up), and
|
|
57
|
-
versions must live in a shared store. [On Workers and serverless](/guides/live-data#on-workers-and-serverless)
|
|
58
|
-
has the details.
|
|
45
|
+
On Cloudflare it is Workers, not Pages. Cloudflare is moving Pages projects to
|
|
46
|
+
Workers, and the `cloudflare_pages` preset's build does not run: every page
|
|
47
|
+
answers a bare 500. A Workers build serves its static files from the same
|
|
48
|
+
deploy, which is what Pages was for.
|
|
59
49
|
|
|
60
50
|
## Running it
|
|
61
51
|
|
|
@@ -72,9 +62,12 @@ npm run preview # wrangler dev, on workerd
|
|
|
72
62
|
npm run deploy # nitro deploy --prebuilt
|
|
73
63
|
```
|
|
74
64
|
|
|
65
|
+
On Bun, run Vite on Bun's runtime too. [Running on Bun](/hosts/bun) shows the
|
|
66
|
+
scripts.
|
|
67
|
+
|
|
75
68
|
## Compiling to a single binary
|
|
76
69
|
|
|
77
|
-
Bun
|
|
70
|
+
On Bun, the whole application can go inside one file — engine, route
|
|
78
71
|
tree, frozen pages and assets, the precompressed variants included:
|
|
79
72
|
|
|
80
73
|
```bash
|
|
@@ -82,39 +75,61 @@ npm run compile # builds, then bun build --compile --splitting .output/server/
|
|
|
82
75
|
./dist/app
|
|
83
76
|
```
|
|
84
77
|
|
|
78
|
+
You deploy the binary and nothing else: not `.output/public`, not
|
|
79
|
+
`.output/server`. A `Dockerfile` copies `dist/app` and runs it:
|
|
80
|
+
|
|
81
|
+
```dockerfile title="Dockerfile"
|
|
82
|
+
FROM debian:bookworm-slim
|
|
83
|
+
COPY dist/app /srv/app
|
|
84
|
+
WORKDIR /srv
|
|
85
|
+
CMD ["./app"]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
One exception: an app with [native packages](#native-packages-in-a-binary)
|
|
89
|
+
needs a directory the binary can write to, because it writes them there the
|
|
90
|
+
first time it starts.
|
|
91
|
+
|
|
92
|
+
### Building once on a deploy
|
|
93
|
+
|
|
85
94
|
`compile` is `vite build && bun run compile:binary`, and `compile:binary` is
|
|
86
95
|
the `bun build --compile` alone. After a build has run, `bun run
|
|
87
96
|
compile:binary` compiles what is already there; a deploy runs that one, so it
|
|
88
|
-
builds once
|
|
89
|
-
builds twice on a deploy, and the build says so until it is split.
|
|
97
|
+
builds once:
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
```bash
|
|
100
|
+
bun run build
|
|
101
|
+
bun run compile:binary
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
An older app whose `compile` holds both steps works the same but builds twice
|
|
105
|
+
on a deploy, and the build says so until it is split.
|
|
106
|
+
|
|
107
|
+
`compile` builds first on purpose. Compiling whatever `.output` happens to hold
|
|
108
|
+
means a binary one version behind the source with nothing to say so — and on a
|
|
109
|
+
project that has never been built, an `ENOENT` naming a path the app did not
|
|
110
|
+
write.
|
|
111
|
+
|
|
112
|
+
### Running a command from the binary
|
|
100
113
|
|
|
101
114
|
`./app` starts the server. If the app has [`src/commands`](/guides/commands/),
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
the binary runs one of them instead, without starting the server:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
./app migrate # runs src/commands/migrate.ts
|
|
119
|
+
./app --help # lists the commands
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The same files run from a plain build as
|
|
104
123
|
`node .output/server/commands.mjs migrate`, so a release step or a worker does
|
|
105
124
|
not need the binary or Bun. The scaffold compiles with `--splitting`, so that a
|
|
106
125
|
stop that arrives while Bun parses the binary is held for a worker rather than
|
|
107
126
|
ending the process: [where a stop is held from](/guides/commands/#where-a-stop-is-held-from).
|
|
108
127
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
128
|
+
### Starting faster with bytecode
|
|
129
|
+
|
|
130
|
+
Add `--bytecode --format=esm` to the `bun build --compile` in your
|
|
131
|
+
`compile:binary` script.
|
|
113
132
|
|
|
114
|
-
Partially prerendered pages are resumed inside the binary exactly as they are
|
|
115
|
-
by the built server. Compiling merges every module into one scope and renames
|
|
116
|
-
whatever collides — `--keep-names` does not prevent that — so the build pins
|
|
117
|
-
each component's name as a `displayName` the shell can rely on. No flag.
|
|
118
133
|
|
|
119
134
|
`--compile` implies `--production`; `--target bun` is the default. `--bytecode`
|
|
120
135
|
compiles the JavaScript ahead of time for a faster cold start at the cost
|
|
@@ -134,17 +149,19 @@ bytecode, as a module.
|
|
|
134
149
|
|
|
135
150
|
### Native packages in a binary
|
|
136
151
|
|
|
152
|
+
A binary that uses `sharp` carries sharp's files, and writes them to disk on
|
|
153
|
+
its first start:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
[rsc-kit] native packages: wrote 189 files to /srv/app/runtime/c3a3844a949c748c
|
|
157
|
+
```
|
|
158
|
+
|
|
137
159
|
`bun build --compile` bundles a package's JavaScript into the binary, and a
|
|
138
160
|
native package then looks for its `.node` file beside a module that is no
|
|
139
161
|
longer on disk. Compiled as-is, a binary that uses `sharp` starts, then dies
|
|
140
162
|
the first time it imports sharp. So when the build traced
|
|
141
163
|
[native packages](#native-dependencies-stay-outside-the-bundle), the binary
|
|
142
|
-
carries those packages' files
|
|
143
|
-
loads them from there:
|
|
144
|
-
|
|
145
|
-
```text
|
|
146
|
-
[rsc-kit] native packages: wrote 189 files to /srv/app/runtime/c3a3844a949c748c
|
|
147
|
-
```
|
|
164
|
+
carries those packages' files and loads them from disk.
|
|
148
165
|
|
|
149
166
|
They go to `$RSC_KIT_RUNTIME_DIR/<hash>/`, or to a folder beside the binary
|
|
150
167
|
when the variable is unset. The binary needs to be able to write there. On a
|
|
@@ -195,7 +212,13 @@ loading sharp's library and heic-convert's WebAssembly, as any server that
|
|
|
195
212
|
imports them does. Requests are unaffected, because the packages are already
|
|
196
213
|
loaded by then.
|
|
197
214
|
|
|
198
|
-
|
|
215
|
+
### Compiling for another platform
|
|
216
|
+
|
|
217
|
+
Name the server's platform in the compile script:
|
|
218
|
+
|
|
219
|
+
```json title="package.json"
|
|
220
|
+
"compile:binary": "bun build --compile --splitting --target=bun-linux-x64 .output/server/compile.mjs --outfile dist/app"
|
|
221
|
+
```
|
|
199
222
|
|
|
200
223
|
Nitro traces the packages installed on the build machine. On a Mac those are
|
|
201
224
|
the Mac's: `@img/sharp-darwin-arm64`, not the linux one a server needs. When
|
|
@@ -221,24 +244,30 @@ packages on your machine. `--target=bun-linux-x64-musl`, for Alpine, asks for
|
|
|
221
244
|
the `linuxmusl` packages. A plain `bun run build` only warns, since it may
|
|
222
245
|
never be compiled.
|
|
223
246
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
247
|
+
### Keep `serveStatic: 'inline'`
|
|
248
|
+
|
|
249
|
+
Without it the binary compiles, starts, serves pages, and 404s every asset.
|
|
250
|
+
Inside a compiled binary the static path resolves into Bun's virtual
|
|
251
|
+
filesystem — where the files on disk are not — and the failure is
|
|
252
|
+
`ENOENT: /$bunfs/public/assets/…` with the pages themselves looking fine.
|
|
253
|
+
The generated config sets it. If you write your own, set it too.
|
|
254
|
+
|
|
255
|
+
## Native dependencies stay outside the bundle
|
|
256
|
+
|
|
257
|
+
For a native package that is not on the default list, name it:
|
|
258
|
+
|
|
259
|
+
```ts title="vite.config.ts"
|
|
260
|
+
rscKit({ serverExternalPackages: ['@acme/native-thing'] })
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
A package with a native binary — `sharp`, `bcrypt`, `better-sqlite3`,
|
|
264
|
+
`@prisma/client` — cannot be rolled into a server bundle: the build succeeds
|
|
265
|
+
and the server cannot load its own binary. The usual ones are left external
|
|
266
|
+
by default, and Nitro traces each into `.output/server/node_modules` with its
|
|
267
|
+
binaries, so the deployment is still one directory.
|
|
268
|
+
|
|
269
|
+
A compiled binary carries them and writes them to disk on its first start. See
|
|
270
|
+
[native packages in a binary](#native-packages-in-a-binary).
|
|
242
271
|
|
|
243
272
|
## Reading a stack trace
|
|
244
273
|
|
|
@@ -269,23 +298,134 @@ Source maps do not change this today:
|
|
|
269
298
|
chunk too (checked with `build.sourcemap` and Nitro's `sourcemap` both on).
|
|
270
299
|
This is Nitro's, and fixing it would help only a Node server.
|
|
271
300
|
|
|
272
|
-
##
|
|
301
|
+
## Compression
|
|
273
302
|
|
|
274
|
-
A
|
|
275
|
-
|
|
276
|
-
and the server cannot load its own binary. The usual ones are left external
|
|
277
|
-
by default, and Nitro traces each into `.output/server/node_modules` with its
|
|
278
|
-
binaries, so the deployment is still one directory. For one that is not on
|
|
279
|
-
the list:
|
|
303
|
+
A bun or node server answering the internet by itself compresses what it
|
|
304
|
+
sends, because nothing in front of it will. There is nothing to turn on.
|
|
280
305
|
|
|
281
|
-
|
|
282
|
-
|
|
306
|
+
The build writes a `.br` and a `.gz` beside every public asset larger than a
|
|
307
|
+
kilobyte, and Nitro serves whichever the request accepts — a 147 kB stylesheet
|
|
308
|
+
is 18 kB on the wire. The host gzips what it answers itself — documents,
|
|
309
|
+
streamed pages, RSC payloads, stored pages, api routes — for a request that
|
|
310
|
+
accepts it, flushing every chunk so a streamed shell still reaches the browser
|
|
311
|
+
before the holes fill; a stored page is compressed once and kept.
|
|
312
|
+
|
|
313
|
+
A port measured what this is worth: with every byte raw, first paint on a
|
|
314
|
+
throttled phone was 3.8 s where 1.2 s was the baseline. That was the whole
|
|
315
|
+
regression.
|
|
316
|
+
|
|
317
|
+
On a Worker the platform compresses and the host does nothing. Behind a
|
|
318
|
+
CDN or nginx that compresses, the proxy sees an already-encoded answer and
|
|
319
|
+
passes it through. The dev server answers raw.
|
|
320
|
+
|
|
321
|
+
### Leaving it to a proxy
|
|
322
|
+
|
|
323
|
+
To skip the precompressed assets, give Nitro the setting as an object.
|
|
324
|
+
`compressPublicAssets: false` is not enough: Nitro's default is already
|
|
325
|
+
`false`, so the build cannot tell it from unset and turns it on:
|
|
326
|
+
|
|
327
|
+
```ts title="vite.config.ts"
|
|
328
|
+
nitro({ preset: 'bun', serveStatic: 'inline', compressPublicAssets: { gzip: false, brotli: false } })
|
|
283
329
|
```
|
|
284
330
|
|
|
285
|
-
|
|
286
|
-
|
|
331
|
+
`Cache-Control: no-transform` on an answer leaves that answer uncompressed.
|
|
332
|
+
A host adapter that embeds the engine turns the host's own gzip off with
|
|
333
|
+
`compress: false` on `createRscHandler`.
|
|
334
|
+
|
|
335
|
+
## Serving assets from nginx or a CDN
|
|
336
|
+
|
|
337
|
+
Point it at `.output/public`. That directory is the deployment:
|
|
287
338
|
|
|
288
|
-
|
|
339
|
+
```nginx
|
|
340
|
+
location /assets/ {
|
|
341
|
+
root /srv/app/.output/public;
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
The build writes browser assets to `.output/public`, and Nitro serves them from
|
|
346
|
+
its own root, in the same process that serves your pages. There is no
|
|
347
|
+
`assetsDir` or `assetsUrl` to set: both were removed, and `rscKit()` refuses a
|
|
348
|
+
config that still passes them rather than reading a prefix and ignoring it.
|
|
349
|
+
The silent version — the markup asks for the app's prefix, Nitro answers at its
|
|
350
|
+
own — left a page unstyled and never hydrated, with nothing logged anywhere.
|
|
351
|
+
|
|
352
|
+
## Streams on serverless platforms
|
|
353
|
+
|
|
354
|
+
`events()` routes and `refreshOn` hold a connection open. On Workers and
|
|
355
|
+
serverless functions each isolate or instance watches for its own tabs, a
|
|
356
|
+
platform's request limits cut streams (they reconnect and catch up), and
|
|
357
|
+
versions must live in a shared store. [On Workers and serverless](/guides/live-data-in-production#on-workers-and-serverless)
|
|
358
|
+
has the details.
|
|
359
|
+
|
|
360
|
+
## Working offline
|
|
361
|
+
|
|
362
|
+
```ts title="vite.config.ts"
|
|
363
|
+
rscKit({ offline: true })
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
That writes a service worker into `.output/public` alongside the assets, so a
|
|
367
|
+
page someone has visited survives a reload with no network. Off by default, and
|
|
368
|
+
covered in [Offline](/guides/offline#working-with-no-network-at-all).
|
|
369
|
+
|
|
370
|
+
## Importing from the right entry point
|
|
371
|
+
|
|
372
|
+
An app imports `redirect` and `revalidate` from their own entry points, even
|
|
373
|
+
when an editor's auto-import offers `host`:
|
|
374
|
+
|
|
375
|
+
| in an app | not |
|
|
376
|
+
| --- | --- |
|
|
377
|
+
| `@rsc-kit/core/redirect` | `@rsc-kit/core/host` |
|
|
378
|
+
| `@rsc-kit/core/revalidate` | `@rsc-kit/core/host` |
|
|
379
|
+
|
|
380
|
+
`@rsc-kit/core/host` is the engine's front door for a **host adapter** — the
|
|
381
|
+
handler, and beside it the few functions an adapter needs when it embeds the
|
|
382
|
+
engine. Several of those are re-exports of app-facing modules. They are the
|
|
383
|
+
same functions, but only an adapter imports `host`. The re-exports there are
|
|
384
|
+
marked internal, so they sort below the app entry in a completion list.
|
|
385
|
+
|
|
386
|
+
## How it works
|
|
387
|
+
|
|
388
|
+
### Why `nitro` is pinned
|
|
389
|
+
|
|
390
|
+
The generated `package.json` pins an exact version rather than a range:
|
|
391
|
+
|
|
392
|
+
```json
|
|
393
|
+
"nitro": "3.0.261103-rc"
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Nitro's own `latest` tag is a dated prerelease, and it sorts **above** the plain
|
|
397
|
+
`3.0.0` on npm. So `^3.0.0` resolves to the older release, which builds without
|
|
398
|
+
complaint and then answers 404 to every route. TanStack Start pins a dated beta
|
|
399
|
+
for the same reason.
|
|
400
|
+
|
|
401
|
+
That version is also the oldest rsc-kit runs on. The build stops with the line to
|
|
402
|
+
change if the app has an older Nitro, `3.0.0` included. A later dated release
|
|
403
|
+
passes.
|
|
404
|
+
|
|
405
|
+
### A Worker serves the frozen pages from a module
|
|
406
|
+
|
|
407
|
+
A Worker has no filesystem, so the directory the build writes is not there
|
|
408
|
+
at request time. The build also writes the same pages as one module beside
|
|
409
|
+
the bundle, `rsc-static-inline.mjs`, which wrangler uploads with the rest
|
|
410
|
+
and the server imports when the directory is missing. Nothing to configure;
|
|
411
|
+
it is why `○` on a Worker means the stored page and not a live render that
|
|
412
|
+
happens to be the same. It counts toward the Worker's script size, which is
|
|
413
|
+
worth knowing on a site with hundreds of frozen pages.
|
|
414
|
+
|
|
415
|
+
### How frozen pages get into a binary
|
|
416
|
+
|
|
417
|
+
`compile.mjs` is written by the build beside the server. It is what puts the
|
|
418
|
+
frozen pages inside the binary: the server reads them through a computed
|
|
419
|
+
import, which a compile cannot see, and this entry imports them by name and
|
|
420
|
+
hands them over before starting the server. Compile `index.mjs` instead and
|
|
421
|
+
the binary still works — it renders those pages live.
|
|
422
|
+
|
|
423
|
+
Partially prerendered pages are resumed inside the binary exactly as they are
|
|
424
|
+
by the built server. Compiling merges every module into one scope and renames
|
|
425
|
+
whatever collides — `--keep-names` does not prevent that — so the build pins
|
|
426
|
+
each component's name as a `displayName` the shell can rely on. No flag.
|
|
427
|
+
|
|
428
|
+
### A polyfill runs first
|
|
289
429
|
|
|
290
430
|
A dependency that checks for a polyfill at module evaluation — `tsyringe`
|
|
291
431
|
wants `Reflect.getMetadata`, under `@peculiar/x509`, under
|
|
@@ -298,11 +438,11 @@ anywhere in it, the build loads it in a Nitro plugin, which the server's
|
|
|
298
438
|
entry evaluates before any of the app is imported; a project without it
|
|
299
439
|
has nothing that checks. Nothing to add to `instrumentation.ts`.
|
|
300
440
|
|
|
301
|
-
|
|
441
|
+
### A dependency's `"use client"` is read
|
|
302
442
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
443
|
+
A dependency is bundled into the server graphs — and so has its
|
|
444
|
+
`"use client"` directives read — when it declares `react` as a peer
|
|
445
|
+
dependency, which is what a React library does. One that imports React
|
|
306
446
|
and never says so (a generated component wrapper, a workspace package with
|
|
307
447
|
`react` under `dependencies`, a package whose author forgot) would be left
|
|
308
448
|
external, and its directive is then a string nobody reads: the server loads
|
|
@@ -327,82 +467,6 @@ dispatcher is null in one of the two. Only direct dependencies are read for
|
|
|
327
467
|
the directive itself — a directive two levels down is the concern of the
|
|
328
468
|
package between, which declared it.
|
|
329
469
|
|
|
330
|
-
## Offline
|
|
331
|
-
|
|
332
|
-
`rscKit({ offline: true })` writes a service worker into `.output/public`
|
|
333
|
-
alongside the assets, so a page someone has visited survives a reload with no
|
|
334
|
-
network. Off by default, and covered in [Offline](/guides/offline#surviving-without-one).
|
|
335
|
-
|
|
336
|
-
## Why `nitro` is pinned
|
|
337
|
-
|
|
338
|
-
The generated `package.json` pins an exact version rather than a range:
|
|
339
|
-
|
|
340
|
-
```json
|
|
341
|
-
"nitro": "3.0.261103-rc"
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Nitro's own `latest` tag is a dated prerelease, and it sorts **above** the plain
|
|
345
|
-
`3.0.0` on npm. So `^3.0.0` resolves to the older release, which builds without
|
|
346
|
-
complaint and then answers 404 to every route. TanStack Start pins a dated beta
|
|
347
|
-
for the same reason.
|
|
348
|
-
|
|
349
|
-
That version is also the oldest rsc-kit runs on. The build stops with the line to
|
|
350
|
-
change if the app has an older Nitro, `3.0.0` included. A later dated release
|
|
351
|
-
passes.
|
|
352
|
-
|
|
353
|
-
## Assets are Nitro's
|
|
354
|
-
|
|
355
|
-
The build writes browser assets to `.output/public`, and Nitro serves them from
|
|
356
|
-
its own root. There is no `assetsDir` or `assetsUrl` to set: both were removed,
|
|
357
|
-
and `rscKit()` refuses a config that still passes them rather than reading a
|
|
358
|
-
prefix and ignoring it.
|
|
359
|
-
|
|
360
|
-
The alternative was the silent version — the markup asks for the app's prefix,
|
|
361
|
-
Nitro answers at its own, and the page arrives unstyled and never hydrates with
|
|
362
|
-
nothing logged anywhere.
|
|
363
|
-
|
|
364
|
-
Assets live in `.output/public` and are served by the same process that serves
|
|
365
|
-
your pages. If you want nginx or a CDN serving them instead, point it at
|
|
366
|
-
`.output/public` — that directory is the deployment.
|
|
367
|
-
|
|
368
|
-
## Nothing is sent raw
|
|
369
|
-
|
|
370
|
-
A bun or node server answering the internet by itself compresses what it
|
|
371
|
-
sends, because nothing in front of it will. The build writes a `.br` and a
|
|
372
|
-
`.gz` beside every public asset larger than a kilobyte, and Nitro serves
|
|
373
|
-
whichever the request accepts — a 147 kB stylesheet is 18 kB on the wire.
|
|
374
|
-
The host gzips what it answers itself — documents, streamed pages, RSC
|
|
375
|
-
payloads, stored pages, api routes — for a request that accepts it, flushing
|
|
376
|
-
every chunk so a streamed shell still reaches the browser before the holes
|
|
377
|
-
fill; a stored page is compressed once and kept.
|
|
378
|
-
|
|
379
|
-
A port measured what this is worth: with every byte raw, first paint on a
|
|
380
|
-
throttled phone was 3.8 s where 1.2 s was the baseline. That was the whole
|
|
381
|
-
regression.
|
|
382
|
-
|
|
383
|
-
On a Worker the platform compresses and the host does nothing. Behind a
|
|
384
|
-
CDN or nginx that compresses, the proxy sees an already-encoded answer and
|
|
385
|
-
passes it through. A deployment that would rather its proxy did all of it
|
|
386
|
-
turns the host's half off with `compress: false` on the handler, and Nitro's
|
|
387
|
-
with `compressPublicAssets: false` in its config; `Cache-Control:
|
|
388
|
-
no-transform` on an answer leaves that answer alone.
|
|
389
|
-
|
|
390
470
|
---
|
|
391
471
|
|
|
392
472
|
Next: [Deploying →](/hosts/deployment)
|
|
393
|
-
|
|
394
|
-
## Which entry point is whose
|
|
395
|
-
|
|
396
|
-
`@rsc-kit/core/host` is the engine's front door for a **host adapter** — the
|
|
397
|
-
handler, and beside it the few functions an adapter needs when it embeds the
|
|
398
|
-
engine. Several of those are re-exports of app-facing modules, so an editor's
|
|
399
|
-
auto-import may offer `redirect` or `revalidate` from `host`. They are the
|
|
400
|
-
same functions; an app imports them from their own entry points:
|
|
401
|
-
|
|
402
|
-
| in an app | not |
|
|
403
|
-
| --- | --- |
|
|
404
|
-
| `@rsc-kit/core/redirect` | `@rsc-kit/core/host` |
|
|
405
|
-
| `@rsc-kit/core/revalidate` | `@rsc-kit/core/host` |
|
|
406
|
-
|
|
407
|
-
Only an adapter imports `host`. The re-exports there are marked internal, so
|
|
408
|
-
they sort below the app entry in a completion list.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsc-kit/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "An MCP server over what an rsc-kit build decided: the routes, why each one is static or not, and what it costs the browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
37
|
-
"create-rsc-kit": "^0.
|
|
37
|
+
"create-rsc-kit": "^0.42.1",
|
|
38
38
|
"zod": "^3.25"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|