@rsc-kit/mcp 0.41.0 → 0.42.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.
Files changed (60) hide show
  1. package/dist/recipes.js +12 -2
  2. package/dist/recipes.js.map +1 -1
  3. package/guides/admin-plugins.md +206 -6
  4. package/guides/api-routes.md +159 -215
  5. package/guides/authorization.md +103 -114
  6. package/guides/backend-answered-pages.md +301 -252
  7. package/guides/bap-vs-inertia.md +67 -25
  8. package/guides/blueprints.md +300 -169
  9. package/guides/bun.md +42 -25
  10. package/guides/caching.md +46 -49
  11. package/guides/coming-from-inertia.md +2 -2
  12. package/guides/commands.md +251 -200
  13. package/guides/connection.md +50 -54
  14. package/guides/content-security-policy.md +133 -84
  15. package/guides/domains.md +190 -149
  16. package/guides/edge-caching.md +242 -268
  17. package/guides/emails.md +96 -45
  18. package/guides/errors.md +116 -137
  19. package/guides/feature-flags.md +100 -30
  20. package/guides/file-uploads.md +101 -26
  21. package/guides/fonts.md +139 -110
  22. package/guides/forms.md +520 -542
  23. package/guides/images.md +87 -28
  24. package/guides/index.json +13 -33
  25. package/guides/instrumentation.md +134 -95
  26. package/guides/isr.md +3 -3
  27. package/guides/live-data-in-production.md +695 -0
  28. package/guides/live-data.md +170 -839
  29. package/guides/mcp.md +83 -59
  30. package/guides/metadata.md +124 -179
  31. package/guides/navigation.md +118 -147
  32. package/guides/no-javascript.md +49 -57
  33. package/guides/offline.md +118 -153
  34. package/guides/openapi.md +100 -35
  35. package/guides/pages.md +160 -50
  36. package/guides/ppr.md +178 -256
  37. package/guides/pwa.md +251 -218
  38. package/guides/queries.md +171 -300
  39. package/guides/react-compiler.md +90 -50
  40. package/guides/redirects.md +141 -177
  41. package/guides/response-headers.md +76 -74
  42. package/guides/route-interception.md +112 -111
  43. package/guides/routing.md +216 -322
  44. package/guides/sections.md +63 -66
  45. package/guides/seo-files.md +127 -65
  46. package/guides/server-actions.md +285 -357
  47. package/guides/static-generation.md +131 -199
  48. package/guides/testing.md +269 -147
  49. package/guides/third-party-scripts.md +94 -47
  50. package/guides/typed-routes.md +115 -113
  51. package/guides/url-validation.md +113 -61
  52. package/guides/validation.md +53 -62
  53. package/guides/view-transitions.md +159 -132
  54. package/guides/where-it-runs.md +226 -162
  55. package/package.json +2 -2
  56. package/guides/admin.md +0 -520
  57. package/guides/deployment.md +0 -598
  58. package/guides/go.md +0 -539
  59. package/guides/laravel.md +0 -787
  60. package/guides/your-own-backend.md +0 -602
package/guides/emails.md CHANGED
@@ -2,25 +2,8 @@
2
2
 
3
3
  > Rendering React to HTML on the server — an email, a PDF, a feed — from a server action or a route, with "use ssr".
4
4
 
5
- An email template is a React component, and `@react-email/render` (or
6
- `renderToString` from `react-dom/server`) turns it into HTML. Call that from
7
- a server action and this comes back:
8
-
9
- ```
10
- Error: react-dom/server is not supported in React Server Components.
11
- ```
12
-
13
- React means it. Where server components render, `react` is a server-only
14
- build: the renderer needs the client build's internals, and the components it
15
- would render import that same `react` — no `useState`, no `useContext`. Nothing
16
- that renders React to HTML can run there, and no alias fixes that. It has to
17
- run in the **ssr** environment, which every app here already has: the one that
18
- turns your pages into HTML for the browser.
19
-
20
- ## `"use ssr"`
21
-
22
- Put the rendering — the template and the call that renders it — in a module
23
- that starts with the directive:
5
+ To render React to an HTML string on the server, for an email, a PDF or a feed,
6
+ put the rendering in a module that starts with `"use ssr"`:
24
7
 
25
8
  ```tsx title="src/lib/email/render.tsx"
26
9
  "use ssr";
@@ -40,7 +23,7 @@ export async function renderOtpEmail(code: string) {
40
23
  }
41
24
  ```
42
25
 
43
- Everything else imports it normally:
26
+ Then import it from anywhere, a server action included:
44
27
 
45
28
  ```ts title="src/lib/email/send-otp.ts"
46
29
  import { renderOtpEmail } from './render';
@@ -52,34 +35,93 @@ export async function sendOtpEmail(to: string, code: string) {
52
35
  }
53
36
  ```
54
37
 
55
- The module runs in the ssr environment, in the same process. Where server
56
- components render, the build replaces it with proxies of its exports that call
57
- across — the same thing `"use client"` does for a component, in the other
58
- direction. In development that is a call into the ssr module runner; in a
59
- build the module is part of the ssr bundle and the proxies import it from
60
- there. Nothing to configure.
38
+ There's nothing to configure.
39
+
40
+ ## Why it needs the directive
41
+
42
+ Without it, a server action that calls `@react-email/render` (or
43
+ `renderToString` from `react-dom/server`) fails:
44
+
45
+ ```
46
+ Error: react-dom/server is not supported in React Server Components.
47
+ ```
48
+
49
+ Where server components render, `react` is a server-only build, with no
50
+ `useState` and no `useContext`. Rendering React to HTML needs the client build,
51
+ so it can't run there, and no alias fixes that. It has to run in the **ssr**
52
+ environment, which every app already has: it's the one that turns your pages
53
+ into HTML for the browser. `"use ssr"` puts a module there.
54
+
55
+ ## Writing an email template
56
+
57
+ The template is an ordinary component, with no directive:
58
+
59
+ ```tsx title="src/lib/email/otp-email.tsx"
60
+ import { Html, Body, Heading, Text } from '@react-email/components';
61
+
62
+ export function OtpEmail({ code }: { code: string }) {
63
+ return (
64
+ <Html>
65
+ <Body>
66
+ <Heading>Your sign-in code</Heading>
67
+ <Text>{code}</Text>
68
+ </Body>
69
+ </Html>
70
+ );
71
+ }
72
+ ```
73
+
74
+ Only the `"use ssr"` module imports it, so it's bundled for the ssr
75
+ environment along with `@react-email/components`.
76
+
77
+ ## Rendering HTML in an API route
78
+
79
+ A route that answers with a standalone HTML document, such as a printable
80
+ invoice, calls the same kind of module:
81
+
82
+ ```tsx title="src/lib/invoices/render.tsx"
83
+ "use ssr";
84
+
85
+ import { renderToString } from 'react-dom/server';
86
+ import { InvoiceDocument } from './invoice-document';
87
+
88
+ export async function renderInvoice(invoice: Invoice) {
89
+ return '<!doctype html>' + renderToString(<InvoiceDocument invoice={invoice} />);
90
+ }
91
+ ```
92
+
93
+ ```ts title="src/app/invoices/[id]/print/route.ts"
94
+ import type { RouteContext } from '@rsc-kit/core/route-schema';
95
+ import { renderInvoice } from '@/lib/invoices/render';
96
+
97
+ export async function GET(request: Request, { params }: RouteContext<'/invoices/[id]/print'>) {
98
+ const { id } = await params;
99
+ const html = await renderInvoice(await findInvoice(id));
100
+
101
+ return new Response(html, { headers: { 'Content-Type': 'text/html; charset=utf-8' } });
102
+ }
103
+ ```
61
104
 
62
105
  ## The rules
63
106
 
64
107
  **Exports are async functions.** A call crosses environments, so the answer is
65
108
  a promise. A function declared without `async` is refused at build with its
66
- name; so is a value, a class, `export { … }` or `export *`. Types are fine.
109
+ name, and so is a value, a class, `export { … }` or `export *`. Types are fine.
67
110
 
68
- **Pass data across, not elements.** The template is created inside the module,
69
- from the arguments — `renderOtpEmail(code)`, not `render(<OtpEmail />)` from
70
- the caller. An element built where server components render carries
71
- components from that side's `react`, and they would render with no hooks.
111
+ **Pass data across, not elements.** Create the template inside the module from
112
+ the arguments: `renderOtpEmail(code)`, not `render(<OtpEmail />)` from the
113
+ caller. An element built where server components render carries components
114
+ from that side's `react`, and they would render with no hooks.
72
115
 
73
116
  **The module's imports belong to the ssr side.** `@react-email/components`,
74
- `react-dom/server`, a PDF renderer, a Markdown library that uses React — all
75
- resolved and bundled for the ssr environment. A database client works there
76
- too, but belongs on the calling side; keep the module to rendering.
117
+ `react-dom/server`, a PDF renderer or a Markdown library that uses React are
118
+ all resolved and bundled for the ssr environment. A database client works
119
+ there too, but it belongs on the calling side. Keep the module to rendering.
77
120
 
78
- ## If you import it directly anyway
121
+ ## If you import react-dom/server directly
79
122
 
80
- `react-dom/server` imported where server components render — through a
81
- library, usually — now fails with the fix in the message rather than React's
82
- refusal:
123
+ `react-dom/server` imported where server components render, usually through a
124
+ library, fails with the fix in the message instead of React's refusal:
83
125
 
84
126
  ```
85
127
  react-dom/server cannot run where server components render … Imported by
@@ -87,16 +129,25 @@ src/lib/nodemailer.ts. Put the rendering — the template and the call — in a
87
129
  module that starts with "use ssr" …
88
130
  ```
89
131
 
90
- A build prints the same once, as a warning, naming the file — and the
91
- build still succeeds, because the refusal is the call's, not the import's:
92
- every export of the stub throws it when called, so a server does not fail to
93
- boot over an action nobody has run yet.
132
+ A build prints the same message once, as a warning naming the file, and still
133
+ succeeds. The refusal belongs to the call, not the import: every export of the
134
+ stub throws it when called, so a server doesn't fail to boot over an action
135
+ nobody has run yet.
94
136
 
95
- A dependency whose imports the build never looks inside — `@react-email/render`
96
- imported from an action, say — is read once for the import and warned about
97
- the same way, naming the app file and the package:
137
+ A dependency whose imports the build never looks inside, such as
138
+ `@react-email/render` imported from an action, is read once for the import and
139
+ warned about the same way, naming the app file and the package:
98
140
 
99
141
  ```
100
142
  src/actions/send-otp.ts imports @react-email/render, which imports
101
143
  react-dom/server, and that cannot run where server components render …
102
144
  ```
145
+
146
+ ## How it works
147
+
148
+ A `"use ssr"` module runs in the ssr environment, in the same process. Where
149
+ server components render, the build replaces it with proxies of its exports
150
+ that call across. It's what `"use client"` does for a component, in the other
151
+ direction. In development, the proxy calls into the ssr module runner. In a
152
+ build, the module is part of the ssr bundle, and the proxies import it from
153
+ there.
package/guides/errors.md CHANGED
@@ -2,21 +2,20 @@
2
2
 
3
3
  > What a visitor sees when a page throws, or asks for a url nothing answers.
4
4
 
5
- Two files, both optional, both following the same rule as `loading.tsx`: the
6
- nearest one wins.
5
+ An `error.tsx` is what a visitor sees when a page throws, and a `not-found.tsx`
6
+ is what they see for a page that doesn't exist. Both are optional, and the one
7
+ nearest the page wins.
7
8
 
8
- ## When a page throws
9
-
10
- With nothing of your own, a page that throws shows the engine's error page
11
- where the page was, and the layouts around it stay: in development the
12
- message and stack, in production "Something went wrong" with the digest to
13
- search the server log for, and a **Try again** in both. It used to show
14
- nothing — React unmounted the document on hydration, a black page with the
15
- cause nowhere near it.
9
+ ```text
10
+ src/app/
11
+ not-found.tsx any url no route matches
12
+ orders/
13
+ error.tsx anything under /orders that throws
14
+ ```
16
15
 
17
- That page is the fallback. To show something of your own:
16
+ ## Showing an error page
18
17
 
19
- Put an `error.tsx` in the directory you want to cover:
18
+ Put an `error.tsx` in the folder you want to cover:
20
19
 
21
20
  ```tsx title="src/app/orders/error.tsx"
22
21
  'use client'
@@ -35,42 +34,42 @@ export default function OrdersError({ error, reset }: RouteErrorProps) {
35
34
  ```
36
35
 
37
36
  Anything below it that throws renders this instead. The layouts above stay on
38
- screen — only the segment that failed is replaced.
37
+ screen; only the part that failed is replaced.
38
+
39
+ It must start with `'use client'`, or the build refuses it. Catching a render
40
+ error happens in the browser, and `reset` is a callback the browser calls.
39
41
 
40
- `reset()` asks the server for the page again and renders what it answers, for
41
- a failure that might not happen twice - a service that was down for a moment.
42
- The layouts stay, and the error stays on screen until the new page is in hand.
43
- If the page fails again, the error is shown again. It is the whole retry: do
44
- not call `refresh()` beside it or reload the document. Navigating away clears
45
- the error on its own.
42
+ Without an `error.tsx`, a page that throws shows the engine's error page where
43
+ the page was, with the layouts around it kept and a **Try again** button. In
44
+ development it shows the message and stack; in production, "Something went
45
+ wrong" and the digest to search the server log for.
46
46
 
47
- :::caution[It has to be a client component]
48
- `'use client'` at the top, or the build refuses it. Catching a render error is
49
- a class component's job, it runs in the browser, and `reset` is a callback the
50
- browser calls — none of which a server component can do.
51
- :::
47
+ ### Trying again
52
48
 
53
- ### What `error.message` says in production
49
+ `reset()` asks the server for the page again and renders the answer. It suits
50
+ a failure that might not happen twice, such as a service that was down for a
51
+ moment. The error stays on screen until the new page arrives, and shows again
52
+ if the page fails again. Don't call `refresh()` beside it or reload the
53
+ document. Navigating away clears the error too.
54
54
 
55
- React replaces it with a generic sentence and puts a hash on `error.digest`.
56
- That is React, not this package: the real message could name a table, a query or
57
- a path, and none of that should reach a browser.
55
+ ### The message in production
58
56
 
59
- Log the digest where you log the error, and the two line up.
57
+ React replaces `error.message` with a generic sentence and puts a hash on
58
+ `error.digest`, so a message naming a table, a query or a path never reaches a
59
+ browser. Log the digest where you log the error, and the two line up.
60
60
 
61
- ### It does not catch everything
61
+ ### What it doesn't catch
62
62
 
63
- - **Errors in the layout above it.** The boundary sits inside that layout, so a
64
- layout that throws needs an `error.tsx` a directory up. The engine's own
65
- page is outermost and catches those too.
66
- - **The build.** A page that throws every time it renders fails the build
67
- rather than shipping a stored error page. The boundary is for a request that
68
- goes wrong, not a page that is broken.
63
+ - **A layout above it that throws.** The boundary sits inside that layout, so
64
+ put an `error.tsx` a folder higher. The engine's own error page is outermost
65
+ and catches those too.
66
+ - **A page that throws every time it renders.** That fails the build instead of
67
+ shipping a stored error page.
69
68
 
70
- ### Telling a refusal apart in a server component
69
+ ## Handling a refusal in a server component
71
70
 
72
- A failed `rpc()` throws the engine's own error for a refusal, so a server
73
- component can answer it rather than fail:
71
+ A refused `rpc()` throws an error you can check for, so a server component can
72
+ show something else instead of failing:
74
73
 
75
74
  ```tsx
76
75
  import { ServerAuthenticationError } from '@rsc-kit/core/errors'
@@ -85,46 +84,20 @@ async function Invite({ token }: { token: string }) {
85
84
  }
86
85
  ```
87
86
 
88
- `ServerAuthenticationError` is a 401 from the backend, `ServerAuthorizationError`
89
- a 403. A refusal the backend gave a status of its own (`abort(429)`, Go's
90
- `Refuse(503, …)`) carries it as `error.refusalStatus` beside the backend's own
91
- message, and uncaught the page answers that status. Rethrow what you do not
92
- handle, so a not-found or a redirect still does what it should.
87
+ | Error | When |
88
+ | --- | --- |
89
+ | `ServerAuthenticationError` | the backend answered 401 |
90
+ | `ServerAuthorizationError` | the backend answered 403 |
93
91
 
94
- ### A server module in the browser bundle
92
+ A refusal with a status of its own (`abort(429)`, Go's `Refuse(503, …)`)
93
+ carries it as `error.refusalStatus`, beside the backend's message. Left
94
+ uncaught, the page answers with that status.
95
95
 
96
- ```txt
97
- [rsc-kit] '@rsc-kit/core/redirect' is for the server, and ended up in the browser bundle:
98
- imported by src/lib/team.ts
99
- which is imported by src/app/teams/controls.tsx
100
- ```
96
+ Rethrow what you don't handle, so a not-found or a redirect still works.
97
+
98
+ ## Showing a 404 page
101
99
 
102
- The build stops, and in dev the module fails to load, when a file the browser
103
- imports reaches `request`, `redirect`, `revalidate`, `cache`, `section`, or
104
- anything else of this package that only makes sense on a server. The usual
105
- cause is a helper file that two kinds of code share: a page calls its
106
- `redirect()`, and a client component imports its `label()`. The import loads,
107
- nothing in the browser calls it, and the only trace used to be Vite saying a
108
- Node builtin had been "externalized for browser compatibility" — while the
109
- server's request-scope code shipped to every visitor.
110
-
111
- Split the file. What needs the server module goes in one only server components
112
- import; what a client component needs goes in the other. A type-only import is
113
- erased and never counts.
114
-
115
- Mark your own server-only files the same way, with `import 'server-only'`.
116
- The build honours it the same way: a client file that reaches it fails with
117
- the files that brought it there. (This package cannot put that import in its own
118
- modules, because the real package throws under any runtime that is not a
119
- server-components build — a unit test of anything calling `cookies()` included.)
120
-
121
- ## When nothing answers the url
122
-
123
- `src/app/not-found.tsx` is rendered for any url no route matches — and a
124
- client-side navigation to one renders it in place, layout kept, url changed,
125
- status still 404, the way Next.js does once the page is overridden. Without
126
- the file, a navigation to a missing url is a full document load of a plain
127
- "Not found":
100
+ `src/app/not-found.tsx` renders for any url no route matches:
128
101
 
129
102
  ```tsx title="src/app/not-found.tsx"
130
103
  import Link from '@rsc-kit/core/Link'
@@ -139,31 +112,28 @@ export default function NotFound() {
139
112
  }
140
113
  ```
141
114
 
142
- It renders through your root layout like any other page, and is served with a
143
- real **404** — a page that says "not found" under a `200` is a page search
144
- engines index.
115
+ - It renders inside your root layout, with a real **404** status, so search
116
+ engines don't index it.
117
+ - It is a server component, so it can be `async` and read cookies.
118
+ - A client-side navigation to a missing url renders it in place, with the
119
+ layout kept and the url changed.
145
120
 
146
- An ordinary server component, so it can be `async` and read whatever it likes,
147
- the visitor's cookies included. Without one, an unmatched url gets a plain
148
- `Not found` string.
121
+ Without one, an unmatched url gets a plain `Not found`, and a navigation to it
122
+ is a full page load.
149
123
 
150
- Only a request that can show a page gets it: a navigation, or one that accepts
151
- HTML. A missing image, script or stylesheet — a browser's `/favicon.ico` — is
152
- answered with a plain 404 at once, without rendering your layouts for it.
124
+ Only a request that can show a page gets it. A missing image, script, font or
125
+ stylesheet - a browser's `/favicon.ico` - gets a plain 404 at once. This holds
126
+ under a dynamic route like `/[team]` too: a request the browser marks as one of
127
+ those (`Sec-Fetch-Dest`) gets a plain 404 before any of the route's middleware
128
+ runs. A `route.ts` still answers it, since an image endpoint is a route, not a
129
+ page.
153
130
 
154
- The same holds under a dynamic route. `/[team]` claims nearly every path, but
155
- a page never answers an image, a script, a stylesheet or a font: a request the
156
- browser marks as one (`Sec-Fetch-Dest`) gets a plain 404 before any of the
157
- route's middleware runs. A `route.ts` still answers such a request — an image
158
- endpoint is a route, not a page — and a navigation, a `fetch()`, or a client
159
- that does not say, gets the page as always.
131
+ ### A 404 page for one part of the site
160
132
 
161
- ### A section's own 404
133
+ A `not-found.tsx` beside a layout answers `notFound()` from every page under
134
+ it, inside that layout:
162
135
 
163
- A `not-found.tsx` beside a layout answers a `notFound()` from every page under
164
- it, inside that layout, the way an `error.tsx` catches what fails under it:
165
-
166
- ```
136
+ ```text
167
137
  src/app/
168
138
  layout.tsx
169
139
  not-found.tsx ← an unmatched url, and anything outside the shop
@@ -173,17 +143,15 @@ src/app/
173
143
  c/[category]/[sub]/[product]/page.tsx
174
144
  ```
175
145
 
176
- The nearest one above the page that said so wins. Called from a page's body, a
177
- `Suspense`-wrapped read or a `middleware.ts`, it is the same file, and the
178
- layouts above it stay on screen; the ones between it and the page are replaced
179
- with it, since it stands in for them. A url no route owns has no page to be
180
- under, so only the root `not-found.tsx` answers it: a section's does not leak
181
- out to the whole site.
146
+ The nearest one above the page that said so wins, whether `notFound()` came
147
+ from the page's body, a read under `<Suspense>` or a `middleware.ts`. An url no
148
+ route owns has no page to be under, so only the root `not-found.tsx` answers
149
+ it.
182
150
 
183
- ### When the page has to decide
151
+ ## When the page has to decide
184
152
 
185
- A url can match a route and still name nothing — `/posts/42` is a real route
186
- and there may be no post 42. Only the page can know that, so the page says so:
153
+ `/posts/42` matches a route, but there may be no post 42. Call `notFound()`
154
+ from the page:
187
155
 
188
156
  ```tsx title="src/app/posts/[slug]/page.tsx"
189
157
  import { notFound } from '@rsc-kit/core/not-found'
@@ -197,35 +165,46 @@ export default async function PostPage({ params }) {
197
165
  }
198
166
  ```
199
167
 
200
- Same page, same **404**. It throws, so nothing after it runs — and if you wrap
201
- the call in a `try`/`catch`, rethrow what you do not recognise, or a missing
202
- page becomes a blank region.
203
-
204
- :::caution[Where you call it decides the status]
205
- Called above every Suspense boundary — at the top of a page, in a layout —
206
- nothing has been written yet, so the response is a real 404.
207
-
208
- Called deeper, inside a boundary, the shell has already gone out with the
209
- status line on it. The status stays `200` — for a person — and the browser
210
- shows your `not-found.tsx` where the page was: it asks the server for it, the
211
- layouts above `not-found.tsx` stay, and the url is the one that was asked for.
212
- It never reaches an `error.tsx`, and nothing in your code checks for it.
213
-
214
- The page ends with `<meta name="robots" content="noindex">`, so a search
215
- engine that reads it does not keep it as a real page.
216
-
217
- A search engine or a link-preview scraper is never sent the shell. It is
218
- answered once the whole page has rendered, so its `notFound()` is a real 404
219
- wherever it was called, a `redirect()` a real redirect, and the metadata is in
220
- `<head>`. The engine recognises them by user agent: Googlebot, Bingbot,
221
- Applebot, DuckDuckBot, Yandex, Baidu, and the preview fetchers of Facebook, X,
222
- LinkedIn, Slack, Discord, WhatsApp, Telegram and others. People never wait for
223
- this.
224
-
225
- A `loading.tsx` is a boundary around its page, so a page under one is always
226
- "deeper". When the answer depends on the request — who is asking, a record
227
- their account can see — make the check in a `middleware.ts` beside the page.
228
- It runs before anything is sent, on every path, including a page the build
229
- stored, and its `notFound()` is a real 404. Its argument is the route's
230
- params, as a plain object: `{ slug: '42' }`.
231
- :::
168
+ It throws, so nothing after it runs. If you wrap it in a `try`/`catch`, rethrow
169
+ what you don't recognise, or the missing page becomes a blank region.
170
+
171
+ ### Where you call it decides the status
172
+
173
+ - **Above every `<Suspense>`** - at the top of a page, or in a layout - nothing
174
+ has been sent yet, and the response is a real 404.
175
+ - **Inside a `<Suspense>` boundary**, the page has already started streaming
176
+ with a `200`. The browser then shows your `not-found.tsx` where the page was,
177
+ with the layouts above it kept and the url unchanged, and adds
178
+ `<meta name="robots" content="noindex">` so search engines skip it.
179
+
180
+ Search engines and link-preview scrapers always get the real status: they are
181
+ answered once the whole page has rendered, so `notFound()` is a 404 and
182
+ `redirect()` a redirect wherever they were called. The engine recognises them
183
+ by user agent - Googlebot, Bingbot, Applebot, DuckDuckBot, Yandex, Baidu, and
184
+ the preview fetchers of Facebook, X, LinkedIn, Slack, Discord, WhatsApp,
185
+ Telegram and others.
186
+
187
+ A page under a `loading.tsx` is always inside a boundary. When a person must
188
+ get a real 404 - a record their account can't see - check in a `middleware.ts`
189
+ beside the page. It runs before anything is sent, even for a page the build
190
+ stored. Its argument is the route's params as a plain object: `{ slug: '42' }`.
191
+
192
+ ## A server module in the browser bundle
193
+
194
+ ```txt
195
+ [rsc-kit] '@rsc-kit/core/redirect' is for the server, and ended up in the browser bundle:
196
+ imported by src/lib/team.ts
197
+ which is imported by src/app/teams/controls.tsx
198
+ ```
199
+
200
+ The build stops, and in development the module fails to load, when a file the
201
+ browser imports reaches `request`, `redirect`, `revalidate`, `cache`,
202
+ `section`, or any other part of this package that only works on a server.
203
+
204
+ The usual cause is a helper file shared by both kinds of code: a page calls its
205
+ `redirect()`, and a client component imports its `label()`. Split it into two
206
+ files - one only server components import, one the client can. A type-only
207
+ import doesn't count.
208
+
209
+ Mark your own server-only files with `import 'server-only'`. A client file that
210
+ reaches one fails the same way, naming the files that brought it there.