Skip to content

Commit c4a5162

Browse files
delbaoliveirahuozhi
authored andcommitted
15.2 docs: document missing htmlLimitedBots option (#76616)
- Minor updates to the new Streaming Metadata section - Document new next.config.ts option: `htmlLimitedBots`
1 parent 07d029f commit c4a5162

File tree

2 files changed

+50
-9
lines changed

2 files changed

+50
-9
lines changed

docs/01-app/04-api-reference/04-functions/generate-metadata.mdx

+16-9
Original file line numberDiff line numberDiff line change
@@ -1197,31 +1197,38 @@ export const metadata = {
11971197
}
11981198
```
11991199
1200-
#### Streaming Metadata
1200+
## Streaming metadata
12011201
1202-
Starting from v15.2, metadata returned by `generateMetadata` will be streamed to the client. This allows Next.js to inject metadata into the HTML as soon as it's resolved.
1202+
Metadata returned by `generateMetadata` is streamed to the client. This allows Next.js to inject metadata into the HTML as soon as it's resolved.
12031203

1204-
Since page metadata often primarily targets bots & crawlers, Next.js will continue to block the render until the metadata is resolved for **HTML-limited bots**.
1205-
1206-
Some bots, like `Googlebot`, can execute JavaScript and are able to inspect the full page DOM, meaning they **don't** require blocking metadata. However, bots like `Twitterbot` **cannot** execute JavaScript while crawling a page—they fall into the **HTML-limited** category.
1204+
Since page metadata primarily targets bots and crawlers, Next.js will stream metadata for bots that can execute JavaScript and inspect the full page DOM (e.g. `Googlebot`). However, metadata will continue blocking the render of the page for **HTML-limited** bots (e.g. `Twitterbot`) as these cannot execute JavaScript while crawling.
12071205

12081206
Next.js automatically detects the user agent of incoming requests to determine whether to serve streaming metadata or fallback to blocking metadata.
12091207

12101208
If you need to customize this list, you can define them manually using the `htmlLimitedBots` option in `next.config.js`. Next.js will ensure user agents matching this regex receive blocking metadata when requesting your web page.
1211-
Specifying a `htmlLimitedBots` config will override the Next.js' default list, allowing you full control over what user agents should opt into this behavior. This is advanced behavior, and the default should be sufficient for most cases.
12121209

1213-
```js filename="next.config.js"
1210+
```ts filename="next.config.ts" switcher
1211+
import type { NextConfig } from 'next'
1212+
1213+
const config: NextConfig = {
1214+
htmlLimitedBots: 'MySpecialBot|MyAnotherSpecialBot|SimpleCrawler',
1215+
}
1216+
1217+
export default config
1218+
```
1219+
1220+
```js filename="next.config.js" switcher
12141221
module.exports = {
12151222
htmlLimitedBots: 'MySpecialBot|MyAnotherSpecialBot|SimpleCrawler',
12161223
}
12171224
```
12181225

1219-
> **Note:** Next.js includes [a default list of HTML limited bots](https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/html-bots.ts)
1226+
Specifying a `htmlLimitedBots` config will override the Next.js' default list, allowing you full control over what user agents should opt into this behavior. This is advanced behavior, and the default should be sufficient for most cases.
12201227
12211228
## Version History
12221229
12231230
| Version | Changes |
12241231
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
1225-
| `v15.2.0` | introduced streaming support to `generateMetadata`. |
1232+
| `v15.2.0` | Introduced streaming support to `generateMetadata`. |
12261233
| `v13.2.0` | `viewport`, `themeColor`, and `colorScheme` deprecated in favor of the [`viewport` configuration](/docs/app/api-reference/functions/generate-viewport). |
12271234
| `v13.2.0` | `metadata` and `generateMetadata` introduced. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: htmlLimitedBots
3+
description: Specify a list of user agents that should receive blocking metadata.
4+
---
5+
6+
The `htmlLimitedBots` config allows you to specify a list of user agents that should receive blocking metadata instead of [streaming metadata](/docs/app/api-reference/functions/generate-metadata#streaming-metadata).
7+
8+
```ts filename="next.config.ts" switcher
9+
import type { NextConfig } from 'next'
10+
11+
const config: NextConfig = {
12+
htmlLimitedBots: 'MySpecialBot|MyAnotherSpecialBot|SimpleCrawler',
13+
}
14+
15+
export default config
16+
```
17+
18+
```js filename="next.config.js" switcher
19+
module.exports = {
20+
htmlLimitedBots: 'MySpecialBot|MyAnotherSpecialBot|SimpleCrawler',
21+
}
22+
```
23+
24+
## Default list
25+
26+
Next.js includes [a default list of HTML limited bots](https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/html-bots.ts).
27+
28+
Specifying a `htmlLimitedBots` config will override the Next.js' default list, allowing you full control over what user agents should opt into this behavior. However, this is advanced behavior, and the default should be sufficient for most cases.
29+
30+
## Version History
31+
32+
| Version | Changes |
33+
| ------- | ------------------------------------ |
34+
| 15.2.0 | `htmlLimitedBots` option introduced. |

0 commit comments

Comments
 (0)