@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.
- package/dist/recipes.js +12 -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 +251 -218
- 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/metadata.md
CHANGED
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
> Titles, descriptions and Open Graph tags, exported from the page.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
A page sets its title and meta tags by exporting `metadata`. React moves the
|
|
6
|
+
tags into `<head>`, so there is no document template to edit:
|
|
7
|
+
|
|
8
|
+
```tsx title="src/app/about/page.tsx"
|
|
9
|
+
import type { Metadata } from '@rsc-kit/core/metadata';
|
|
10
|
+
|
|
11
|
+
export const metadata: Metadata = {
|
|
12
|
+
title: 'About us',
|
|
13
|
+
description: 'Learn more about our team.',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default function AboutPage() {
|
|
17
|
+
return <h1>About us</h1>;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
9
20
|
|
|
10
21
|
## Static metadata
|
|
11
22
|
|
|
23
|
+
`metadata` takes the keys in [the table below](#supported-keys):
|
|
24
|
+
|
|
12
25
|
```tsx title="src/app/about/page.tsx"
|
|
13
26
|
export const metadata: Metadata = {
|
|
14
27
|
title: 'About us',
|
|
@@ -19,24 +32,15 @@ export const metadata: Metadata = {
|
|
|
19
32
|
description: 'Learn more about our team.',
|
|
20
33
|
},
|
|
21
34
|
};
|
|
22
|
-
|
|
23
|
-
export default function AboutPage() {
|
|
24
|
-
return <h1>About us</h1>;
|
|
25
|
-
}
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
`Metadata`
|
|
37
|
+
Import `Metadata` from `@rsc-kit/core/metadata`. The import resolves as soon as
|
|
38
|
+
dependencies are installed, before any build.
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
import type { Metadata } from '@rsc-kit/core/metadata';
|
|
32
|
-
```
|
|
40
|
+
### Custom meta tags
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
resolves as soon as dependencies are installed, where a generated file does not
|
|
36
|
-
exist until something has been built once — so a freshly cloned project no
|
|
37
|
-
longer reports an error on every page it has not built yet.
|
|
42
|
+
A tag without a named key goes under `other`:
|
|
38
43
|
|
|
39
|
-
:::tip[Custom meta tags go under `other`]
|
|
40
44
|
```tsx
|
|
41
45
|
export const metadata: Metadata = {
|
|
42
46
|
title: 'Pricing',
|
|
@@ -44,17 +48,16 @@ export const metadata: Metadata = {
|
|
|
44
48
|
};
|
|
45
49
|
```
|
|
46
50
|
|
|
47
|
-
The named keys are a closed set
|
|
48
|
-
|
|
49
|
-
all.
|
|
50
|
-
:::
|
|
51
|
+
The named keys are a closed set, so a typo such as `titel` fails the
|
|
52
|
+
typecheck.
|
|
51
53
|
|
|
52
54
|
## Metadata from data
|
|
53
55
|
|
|
54
|
-
When the values depend on what the page
|
|
55
|
-
receives the
|
|
56
|
+
When the values depend on what the page loads, export `generateMetadata`. It
|
|
57
|
+
receives the same `params` and `searchParams` a page does:
|
|
56
58
|
|
|
57
59
|
```tsx title="src/app/posts/[slug]/page.tsx"
|
|
60
|
+
import type { GenerateMetadata } from '@rsc-kit/core/metadata';
|
|
58
61
|
import { findPost } from '../../../data';
|
|
59
62
|
|
|
60
63
|
export const generateMetadata: GenerateMetadata<{ slug: string }> = async ({ params }) => {
|
|
@@ -67,42 +70,25 @@ export const generateMetadata: GenerateMetadata<{ slug: string }> = async ({ par
|
|
|
67
70
|
openGraph: { title: post.title, description: post.excerpt, images: post.cover },
|
|
68
71
|
};
|
|
69
72
|
};
|
|
70
|
-
|
|
71
|
-
export default async function PostPage({ params }: { params: Promise<{ slug: string }> }) {
|
|
72
|
-
const { slug } = await params;
|
|
73
|
-
const post = await findPost(slug);
|
|
74
|
-
|
|
75
|
-
return <h1>{post.title}</h1>;
|
|
76
|
-
}
|
|
77
73
|
```
|
|
78
74
|
|
|
79
|
-
It
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
It never holds the page up. A route with a `generateMetadata` — on the page or
|
|
83
|
-
on any layout above it — streams its metadata like any other read: the page
|
|
84
|
-
paints at once, and the `<title>` and meta tags arrive when the lookup
|
|
85
|
-
finishes. A route with only static `metadata` has it in the first bytes, as
|
|
86
|
-
there is nothing to wait for.
|
|
75
|
+
It never holds the page up. The page paints at once, and the `<title>` and meta
|
|
76
|
+
tags stream in when the lookup finishes. A route with only static `metadata`
|
|
77
|
+
has its tags in the first bytes.
|
|
87
78
|
|
|
88
79
|
A search engine or a link-preview scraper is answered once the whole page has
|
|
89
|
-
rendered, so
|
|
90
|
-
[Errors](/guides/errors) for how
|
|
80
|
+
rendered, so it always reads the tags in `<head>`. See
|
|
81
|
+
[Errors](/guides/errors) for how one is recognised.
|
|
91
82
|
|
|
92
|
-
A layout can export `generateMetadata` too
|
|
93
|
-
|
|
94
|
-
page under it
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Metadata always resolves against the **full** layout chain, even when the
|
|
98
|
-
render is partial. A navigation that replaces one segment still produces the
|
|
99
|
-
same `<title>` a full load would, because the template on the outer layout is
|
|
100
|
-
consulted either way.
|
|
83
|
+
A layout can export `generateMetadata` too. Its answer applies to every page
|
|
84
|
+
beneath it that doesn't set its own: a category named in its layout is the
|
|
85
|
+
title of every page under it without one, and the template of the layout above
|
|
86
|
+
still applies.
|
|
101
87
|
|
|
102
88
|
## Title templates
|
|
103
89
|
|
|
104
|
-
A layout
|
|
105
|
-
|
|
90
|
+
A layout sets the shape of every title beneath it. `%s` is the page's own
|
|
91
|
+
title:
|
|
106
92
|
|
|
107
93
|
```tsx title="src/app/layout.tsx"
|
|
108
94
|
export const metadata: Metadata = {
|
|
@@ -110,7 +96,6 @@ export const metadata: Metadata = {
|
|
|
110
96
|
template: '%s | Acme',
|
|
111
97
|
default: 'Acme',
|
|
112
98
|
},
|
|
113
|
-
description: 'The Acme dashboard.',
|
|
114
99
|
};
|
|
115
100
|
```
|
|
116
101
|
|
|
@@ -121,36 +106,39 @@ export const metadata: Metadata = { title: 'Settings' };
|
|
|
121
106
|
```
|
|
122
107
|
|
|
123
108
|
The nearest layout with a template wins, so a nested layout can override the
|
|
124
|
-
one above it. A page
|
|
109
|
+
one above it. A page with no title gets the `default`.
|
|
110
|
+
|
|
111
|
+
Metadata always resolves against the whole layout chain, so a navigation that
|
|
112
|
+
renders only part of the page still gets the title a full load would.
|
|
125
113
|
|
|
126
114
|
## Supported keys
|
|
127
115
|
|
|
128
116
|
| Key | Becomes |
|
|
129
117
|
| --- | --- |
|
|
130
|
-
| `title` | `<title
|
|
118
|
+
| `title` | `<title>`: a string on a page, a template on a layout |
|
|
131
119
|
| `description` | `<meta name="description">` |
|
|
132
|
-
| `keywords` | `<meta name="keywords"
|
|
120
|
+
| `keywords` | `<meta name="keywords">`. `'react, rsc'` and `['react', 'rsc']` give the same tag |
|
|
133
121
|
| `author` | `<meta name="author">` |
|
|
134
|
-
| `robots` | `<meta name="robots"
|
|
135
|
-
| `metadataBase` | nothing itself
|
|
122
|
+
| `robots` | `<meta name="robots">`: a string, or `{ index: false, follow: false }` for `noindex, nofollow`. `googleBot` is `<meta name="googlebot">` |
|
|
123
|
+
| `metadataBase` | nothing itself; it makes every relative URL below absolute |
|
|
136
124
|
| `openGraph` | `<meta property="og:…">`, one per field; each image brings its size and alt |
|
|
137
125
|
| `twitter` | `<meta name="twitter:…">` |
|
|
138
126
|
| `icons` | `<link rel="icon">`, `apple-touch-icon` and so on |
|
|
139
|
-
| `
|
|
127
|
+
| `appleWebApp` | the iPhone home-screen tags |
|
|
128
|
+
| `other` | `<meta name="…">`, or `property=` for an `og:`, `fb:` or `article:` key |
|
|
140
129
|
| anything else | `<meta name="…">` |
|
|
141
130
|
|
|
142
|
-
|
|
143
|
-
the
|
|
131
|
+
The flat spellings, such as `'og:title'` and `'twitter:card'`, still work.
|
|
132
|
+
Prefer the structured objects: they are typed, they take an image with a width
|
|
133
|
+
and height, and they are what a Next app already has.
|
|
144
134
|
|
|
145
135
|
## Charset and viewport
|
|
146
136
|
|
|
147
137
|
Every document gets `<meta charSet="utf-8">` and
|
|
148
|
-
`<meta name="viewport" content="width=device-width, initial-scale=1"
|
|
149
|
-
|
|
150
|
-
never wrote the tag, and a page without a viewport meta is the desktop
|
|
151
|
-
layout on a phone. A layout that renders either tag itself is left alone.
|
|
138
|
+
`<meta name="viewport" content="width=device-width, initial-scale=1">` without
|
|
139
|
+
being asked. A layout that renders either tag itself is left alone.
|
|
152
140
|
|
|
153
|
-
To change the viewport, export
|
|
141
|
+
To change the viewport, export `viewport` from a layout or a page:
|
|
154
142
|
|
|
155
143
|
```tsx
|
|
156
144
|
import type { Viewport } from '@rsc-kit/core/metadata'
|
|
@@ -168,29 +156,14 @@ export const viewport: Viewport = {
|
|
|
168
156
|
}
|
|
169
157
|
```
|
|
170
158
|
|
|
171
|
-
Layouts outer to inner, then the page,
|
|
172
|
-
`colorScheme` become their own meta tags
|
|
159
|
+
Layouts merge from outer to inner, then the page, key by key. `themeColor` and
|
|
160
|
+
`colorScheme` become their own meta tags, and a `themeColor` here wins over the
|
|
173
161
|
web manifest's.
|
|
174
162
|
|
|
175
|
-
The flat spellings — `'og:title'`, `'twitter:card'` — still work and render
|
|
176
|
-
correctly, but the structured objects are the ones to write: they are typed,
|
|
177
|
-
they take an image object with a width and height, and they are what a Next
|
|
178
|
-
app already has.
|
|
179
|
-
|
|
180
|
-
## On an iPhone's home screen
|
|
181
|
-
|
|
182
|
-
`appleWebApp` is Next's shape — `capable`, `title`, `statusBarStyle`,
|
|
183
|
-
`startupImage` — and renders the same tags. Launch screens are simpler as files
|
|
184
|
-
named by their size; see [Splash screens](/guides/pwa#splash-screens).
|
|
185
|
-
|
|
186
|
-
```tsx title="src/app/layout.tsx"
|
|
187
|
-
export const metadata: Metadata = {
|
|
188
|
-
appleWebApp: { capable: true, title: 'Orders', statusBarStyle: 'black-translucent' },
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
163
|
## The share card
|
|
193
164
|
|
|
165
|
+
Set the site-wide parts once, on the root layout:
|
|
166
|
+
|
|
194
167
|
```tsx title="src/app/layout.tsx"
|
|
195
168
|
export const metadata: Metadata = {
|
|
196
169
|
metadataBase: new URL('https://example.com'),
|
|
@@ -205,6 +178,8 @@ export const metadata: Metadata = {
|
|
|
205
178
|
};
|
|
206
179
|
```
|
|
207
180
|
|
|
181
|
+
and each page adds its own:
|
|
182
|
+
|
|
208
183
|
```tsx title="src/app/posts/[slug]/page.tsx"
|
|
209
184
|
export async function generateMetadata({ params }): Promise<Metadata> {
|
|
210
185
|
const post = await findPost((await params).slug);
|
|
@@ -221,29 +196,36 @@ export async function generateMetadata({ params }): Promise<Metadata> {
|
|
|
221
196
|
}
|
|
222
197
|
```
|
|
223
198
|
|
|
224
|
-
|
|
225
|
-
|
|
199
|
+
`openGraph` is replaced whole by a nearer segment's, as in Next, so a page that
|
|
200
|
+
sets its own `openGraph` should repeat the `siteName` it wants.
|
|
226
201
|
|
|
227
202
|
:::caution[`metadataBase` is not optional in production]
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
and
|
|
203
|
+
Facebook, Slack and LinkedIn ignore a relative image URL without saying so, and
|
|
204
|
+
the link unfurls with no image. Set `metadataBase` on the root layout and every
|
|
205
|
+
relative `url`, image and icon below it is made absolute. Without it, an
|
|
206
|
+
`opengraph-image.png` in `app/` goes out as `/_app/opengraph-image.png`, which
|
|
207
|
+
works in a browser and nowhere else.
|
|
208
|
+
:::
|
|
231
209
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
out as `/_app/opengraph-image.png`, which works in a browser and nowhere else.
|
|
210
|
+
`og:` tags render with `property=` and `twitter:` tags with `name=`, because
|
|
211
|
+
that is what each scraper reads.
|
|
235
212
|
|
|
236
|
-
|
|
237
|
-
|
|
213
|
+
## On an iPhone's home screen
|
|
214
|
+
|
|
215
|
+
`appleWebApp` takes `capable`, `title`, `statusBarStyle` and `startupImage`:
|
|
238
216
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
217
|
+
```tsx title="src/app/layout.tsx"
|
|
218
|
+
export const metadata: Metadata = {
|
|
219
|
+
appleWebApp: { capable: true, title: 'Orders', statusBarStyle: 'black-translucent' },
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Launch screens are simpler as files named by their size. See
|
|
224
|
+
[Splash screens](/guides/pwa#splash-screens).
|
|
243
225
|
|
|
244
226
|
## Icons
|
|
245
227
|
|
|
246
|
-
|
|
228
|
+
`icons` takes a string, a list, or an object by role:
|
|
247
229
|
|
|
248
230
|
```tsx
|
|
249
231
|
// One favicon
|
|
@@ -267,28 +249,15 @@ export const metadata: Metadata = {
|
|
|
267
249
|
};
|
|
268
250
|
```
|
|
269
251
|
|
|
270
|
-
Each
|
|
252
|
+
Each one takes `url`, `type`, `sizes`, `color`, `rel`, `media` and
|
|
271
253
|
`fetchPriority`.
|
|
272
254
|
|
|
273
|
-
## How it reaches the document
|
|
274
|
-
|
|
275
|
-
```text
|
|
276
|
-
Build the plugin finds the metadata exports and generates a resolver
|
|
277
|
-
Render the resolver runs alongside the page, against the full layout chain
|
|
278
|
-
Load React hoists <title> and <meta> into <head> as they are emitted
|
|
279
|
-
Navigate the resolved metadata rides on the X-RSC-Meta header, and the
|
|
280
|
-
client updates document.title and the tags in place
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
The last line is why a title is correct after an SPA navigation without the
|
|
284
|
-
page having been re-rendered from the root.
|
|
285
|
-
|
|
286
255
|
## Icons and share images
|
|
287
256
|
|
|
288
|
-
Put
|
|
289
|
-
|
|
257
|
+
Usually you don't need `icons` at all. Put the files in `src/app/` and the
|
|
258
|
+
build finds them:
|
|
290
259
|
|
|
291
|
-
|
|
|
260
|
+
| File | Becomes |
|
|
292
261
|
| --- | --- |
|
|
293
262
|
| `favicon.ico` | served at `/favicon.ico` |
|
|
294
263
|
| `icon.png`, `icon-192.png`, `icon-512.png` | `<link rel="icon">`, and the [manifest](/guides/offline/)'s icons |
|
|
@@ -296,28 +265,33 @@ and no layout to edit:
|
|
|
296
265
|
| `opengraph-image.png` | `<meta property="og:image">` |
|
|
297
266
|
| `twitter-image.png` | `<meta name="twitter:image">`, with the large-card type |
|
|
298
267
|
|
|
299
|
-
The names are Next's
|
|
300
|
-
an app moving between the two should not have to rename its favicon.
|
|
268
|
+
The names are Next's, so an app moving between the two keeps its files.
|
|
301
269
|
|
|
302
|
-
|
|
303
|
-
|
|
270
|
+
Sizes are read from the filename: `icon-192.png` is 192 pixels. So a manifest
|
|
271
|
+
usually lists no icons:
|
|
304
272
|
|
|
305
273
|
```ts title="src/app/manifest.ts"
|
|
306
274
|
export default {
|
|
307
275
|
name: 'Orders',
|
|
308
276
|
themeColor: '#0b0b0c',
|
|
309
|
-
// icons omitted
|
|
277
|
+
// icons omitted: the build uses the icon-*.png beside this file
|
|
310
278
|
} satisfies WebManifest
|
|
311
279
|
```
|
|
312
280
|
|
|
313
|
-
|
|
314
|
-
|
|
281
|
+
They are served under `/_app/`, so they never collide with your `public/`
|
|
282
|
+
files. The favicon is the exception, served at `/favicon.ico` because browsers
|
|
283
|
+
ask for that URL whatever the markup says.
|
|
284
|
+
|
|
285
|
+
A `public/favicon.ico` is answered before the request reaches the app, so it
|
|
286
|
+
hides yours. Laravel's skeleton ships an empty one, which Herd answers with a
|
|
287
|
+
404. Dev start and the build warn when `public/` holds a file at a URL the app
|
|
288
|
+
serves, and name both; delete the one in `public/`.
|
|
315
289
|
|
|
316
290
|
### A page's own share image
|
|
317
291
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
292
|
+
Put an `opengraph-image.png` or `twitter-image.png` in any folder under `app/`
|
|
293
|
+
and it is the card for the pages in that folder and below. The nearest one
|
|
294
|
+
wins:
|
|
321
295
|
|
|
322
296
|
```text
|
|
323
297
|
src/app/
|
|
@@ -326,18 +300,16 @@ src/app/
|
|
|
326
300
|
opengraph-image.png /pricing
|
|
327
301
|
(marketing)/
|
|
328
302
|
laravel/
|
|
329
|
-
opengraph-image.png /laravel, the group never in the
|
|
303
|
+
opengraph-image.png /laravel, the group never in the URL
|
|
330
304
|
blog/[slug]/
|
|
331
305
|
opengraph-image.png every post
|
|
332
306
|
```
|
|
333
307
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
`og:image` with it.
|
|
308
|
+
Each kind is looked up on its own, so a `twitter-image.png` in `pricing/` does
|
|
309
|
+
not bring an `og:image` with it.
|
|
337
310
|
|
|
338
|
-
A page
|
|
339
|
-
rather than adding a second tag
|
|
340
|
-
it meets, so a second after the site's would be a card that never changes:
|
|
311
|
+
A page can name its image in metadata instead, and it replaces the site's
|
|
312
|
+
rather than adding a second tag:
|
|
341
313
|
|
|
342
314
|
```tsx title="src/app/pricing/page.tsx"
|
|
343
315
|
export const metadata: Metadata = {
|
|
@@ -346,52 +318,25 @@ export const metadata: Metadata = {
|
|
|
346
318
|
```
|
|
347
319
|
|
|
348
320
|
The nearer declaration wins, whichever kind it is. An image exported by a page
|
|
349
|
-
beats a file in a folder above it
|
|
350
|
-
exports from `app/`. In the same folder the file wins, as
|
|
351
|
-
`openGraph` that names no images
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
on its next restart, which it does by itself.
|
|
361
|
-
|
|
362
|
-
### Why `app/` and not `public/`
|
|
363
|
-
|
|
364
|
-
`public/` means "serve this file unchanged". These are *read* as well as
|
|
365
|
-
served: an icon's filename decides what goes in the manifest, and its presence
|
|
366
|
-
decides what goes in the head. A file whose name the build interprets belongs
|
|
367
|
-
with the other files whose names the build interprets.
|
|
368
|
-
|
|
369
|
-
They are copied into the build output under `/_app/`, so they never collide
|
|
370
|
-
with something you put in `public/` yourself. The favicon is the exception —
|
|
371
|
-
it is served at `/favicon.ico`, because browsers ask for that url whatever the
|
|
372
|
-
markup says.
|
|
373
|
-
|
|
374
|
-
A `public/favicon.ico` is answered at that url before the request reaches the
|
|
375
|
-
app, so it hides yours. Laravel's skeleton ships an empty one, which Herd
|
|
376
|
-
answers with a 404 — the console says the favicon is not found on an app that
|
|
377
|
-
has one. Dev start and the build warn when `public/` holds a file at a url the
|
|
378
|
-
app serves, and name both; delete the one in `public/`.
|
|
379
|
-
|
|
380
|
-
:::note[Set `metadataBase`]
|
|
381
|
-
The image is emitted as `/_app/opengraph-image.png`, which a scraper will not
|
|
382
|
-
fetch. With `metadataBase` on the root layout it goes out absolute — see [the
|
|
383
|
-
share card](#the-share-card) above.
|
|
384
|
-
:::
|
|
321
|
+
beats a file in a folder above it, and a file in `pricing/` beats one a layout
|
|
322
|
+
exports from `app/`. In the same folder the file wins, as in Next. An
|
|
323
|
+
`openGraph` that names no images leaves the card to the file.
|
|
324
|
+
|
|
325
|
+
- Folders outside the URL tree are not searched: `_private`, `@slot` and
|
|
326
|
+
`(.)intercepted`.
|
|
327
|
+
- Per-folder placement is not yet read for `icon` or `apple-icon`; those are
|
|
328
|
+
the site's.
|
|
329
|
+
- The dev server restarts on its own to pick up a new share image.
|
|
330
|
+
|
|
331
|
+
### A different image per record
|
|
385
332
|
|
|
386
|
-
|
|
333
|
+
`opengraph-image.tsx`, a component Next renders to a PNG at build time, is not
|
|
334
|
+
supported. Make the image once and commit the file. For an image per record,
|
|
335
|
+
such as one per post, write an [API route](/guides/api-routes/) that returns
|
|
336
|
+
it, and point `openGraph.images` at its URL.
|
|
387
337
|
|
|
388
|
-
|
|
389
|
-
time. This package does not, on purpose. Rendering an image means bundling a
|
|
390
|
-
layout engine and a rasteriser — a couple of megabytes of dependencies, and
|
|
391
|
-
seconds added to every build for every image — for a picture that changes
|
|
392
|
-
when the design does, which is to say rarely.
|
|
338
|
+
## How metadata reaches the page
|
|
393
339
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
`openGraph.images` url points at it. Neither touches the build.
|
|
340
|
+
- **Load:** React moves `<title>` and `<meta>` into `<head>` as they render.
|
|
341
|
+
- **Navigation:** the resolved metadata comes back in the `X-RSC-Meta` header,
|
|
342
|
+
and the browser updates `document.title` and the tags in place.
|