Skip to content

Commit 6556a74

Browse files
authored
docs: add note about CF routes limit
1 parent 2ca1db4 commit 6556a74

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

docs/content/1.docs/3.recipes/3.pre-rendering.md

+32-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default defineNuxtConfig({
2525
})
2626
```
2727

28-
When running `nuxt build`, Nuxt will pre-render the `/` route and save the `index.html` file in the output directory.
28+
When running `nuxt build`, Nuxt will pre-render the `/` route and save the `index.html` file in the output directory.
2929

3030
::callout{icon="i-ph-rocket-launch-duotone"}
3131
When deploying with NuxtHub on Cloudflare Pages, it will serve the pre-rendered HTML file directly from the edge for maximum performance and avoid CPU usage on the server.
@@ -50,10 +50,14 @@ defineRouteRules({
5050
This is equivalent of our example above in the `nuxt.config.ts` file.
5151

5252
**Notes:**
53+
5354
- A rule defined in `~/pages/foo/bar.vue` will be applied to `/foo/bar` requests.
5455
- A rule in `~/pages/foo/[id].vue` will be applied to `/foo/**` requests.
5556

56-
::important{to="https://nuxt.com/docs/guide/going-further/experimental-features#inlinerouterules"}
57+
::important
58+
---
59+
to: https://nuxt.com/docs/guide/going-further/experimental-features#inlinerouterules
60+
---
5761
As this is an experimental feature, you need to enable it in your `nuxt.config.ts` files with `experimental: { inlineRouteRules: true }`.
5862
::
5963

@@ -128,10 +132,35 @@ export default defineNuxtConfig({
128132

129133
When running `nuxt build`, Nuxt will pre-render all pages and save the `index.html` file in the `dist/` directory.
130134

131-
::tip{to="https://nuxt.com/docs/getting-started/prerendering" target="_blank"}
135+
::tip{target="_blank" to="https://nuxt.com/docs/getting-started/prerendering"}
132136
Learn more about Nuxt prerendering.
133137
::
134138

139+
### Cloudflare 100 routes limit
140+
141+
NuxtHub will generate a [`dist/_routes.json`](https://developers.cloudflare.com/pages/functions/routing/#create-a-_routesjson-file) for Cloudflare Pages, but it has a limit of 100 excluded routes (used for static assets).
142+
143+
As each pre-rendered page will be added to the exclude list, we recommend to add your known pre-rendered pattern in the `nitro.cloudflare.pages.routes.exclude` option:
144+
145+
```ts [nuxt.config.ts]
146+
export default defineNuxtConfig({
147+
// ...
148+
nitro: {
149+
cloudflare: {
150+
pages: {
151+
routes: {
152+
exclude: [
153+
// we know that all docs and blog pages are pre-rendered
154+
'/docs/*',
155+
'/blog/*'
156+
]
157+
}
158+
}
159+
}
160+
}
161+
})
162+
```
163+
135164
## Caveats
136165

137166
If you are using authentication in your application such as [`nuxt-auth-utils`](https://github.com/Atinux/nuxt-auth-utils), you need to remember that the authentication state will not be available during the pre-rendering process.

0 commit comments

Comments
 (0)