diff --git a/docs/content/3.config/index.md b/docs/content/3.config/index.md
index be37c63d6a..af828e1f9b 100644
--- a/docs/content/3.config/index.md
+++ b/docs/content/3.config/index.md
@@ -279,13 +279,23 @@ routeRules: {
### `prerender`
-Default: `{ crawlLinks: false, ignore: [], routes: [] }`
+Pre-rendering options used when building your application with Nitro.
-Prerendered options. Any route specified will be fetched during the build and copied to the `.output/public` directory as a static asset.
+Default:
-Any route that starts with a prefix listed in `ignore` will be ignored.
+```ts
+{
+ crawlLinks: false,
+ ignore: [],
+ routes: []
+}
+```
+
+Any route specified in `routes` will be fetched during the build and copied to the `.output/public` directory as a static asset.
+
+If `crawlLinks` option is set to `true`, nitro starts crawling `/` by default (or all routes in `routes` array) and for HTML pages extracts `` tags and prerender them as well. Nitro also reads from the `x-nitro-prerender` header send back to crawl extra routes.
-If `crawlLinks` option is set to `true`, nitro starts with `/` by default (or all routes in `routes` array) and for HTML pages extracts `` tags and prerender them as well.
+The `ignore` option accepts an array of string or regex to specify the routes to ignore. Routes that starts with the string or matches the regex will be ignored.
## Directories
diff --git a/src/prerender.ts b/src/prerender.ts
index 80eeba6afb..ec65544903 100644
--- a/src/prerender.ts
+++ b/src/prerender.ts
@@ -112,7 +112,11 @@ export async function prerender(nitro: Nitro) {
// Check for explicitly ignored routes
for (const ignore of nitro.options.prerender.ignore) {
- if (route.startsWith(ignore)) {
+ if (typeof ignore === "string") {
+ if (route.startsWith(ignore)) {
+ return false;
+ }
+ } else if (ignore.test(route)) {
return false;
}
}
diff --git a/src/types/nitro.ts b/src/types/nitro.ts
index 1ba939aa55..29f6c5cbcd 100644
--- a/src/types/nitro.ts
+++ b/src/types/nitro.ts
@@ -208,7 +208,7 @@ export interface NitroOptions extends PresetOptions {
devErrorHandler: NitroErrorHandler;
prerender: {
crawlLinks: boolean;
- ignore: string[];
+ ignore: (string | RegExp)[];
routes: string[];
};