From 94ba2ea0b6024b515437b4aaaa6995aeecfb9eef Mon Sep 17 00:00:00 2001 From: Alan Schio <6757777+schirrel@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:42:05 -0400 Subject: [PATCH] docs: add example on how to disable default routes for ssg (#30729) --- docs/2.guide/1.concepts/3.rendering.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/2.guide/1.concepts/3.rendering.md b/docs/2.guide/1.concepts/3.rendering.md index 41aacb6519..b0b2117ef9 100644 --- a/docs/2.guide/1.concepts/3.rendering.md +++ b/docs/2.guide/1.concepts/3.rendering.md @@ -126,6 +126,26 @@ This will produce three files: The `200.html` and `404.html` might be useful for the hosting provider you are using. +#### Skipping Client Fallback Generation + +When prerendering a client-rendered app, Nuxt will generate `index.html`, `200.html` and `404.html` files by default. However, if you need to prevent any (or all) of these files from being generated in your build, you can use the `'prerender:generate'` hook from [Nitro](/docs/getting-started/prerendering#prerendergenerate-nitro-hook). + +```ts twoslash [nuxt.config.ts] +export default defineNuxtConfig({ + ssr: false, + nitro: { + hooks: { + 'prerender:generate'(route) { + const routesToSkip = ['/index.html', '/200.html', '/404.html'] + if (routesToSkip.includes(route.route)) { + route.skip = true + } + } + } + } +}) +``` + ## Hybrid Rendering Hybrid rendering allows different caching rules per route using **Route Rules** and decides how the server should respond to a new request on a given URL.