Skip to content

Commit 90aeec3

Browse files
committed
docs: enhance static prerendering documentation with automatic route discovery details
1 parent 55a0475 commit 90aeec3

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

docs/start/framework/react/guide/static-prerendering.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,21 @@ title: Static Prerendering
55

66
Static prerendering is the process of generating static HTML files for your application. This can be useful for either improving the performance of your application, as it allows you to serve pre-rendered HTML files to users without having to generate them on the fly or for deploying static sites to platforms that do not support server-side rendering.
77

8-
## Prerendering
8+
## Automatic Static Route Discovery
99

10-
TanStack Start can prerender your application to static HTML files, which can then be served to users without having to generate them on the fly. To prerender your application, you can add the `prerender` option to your tanstackStart configuration in `vite.config.ts` file:
10+
When you don't specify a `pages` array in your prerendering configuration, TanStack Start will automatically discover and prerender all static routes in your application. This includes:
11+
12+
- Routes with no path parameters (e.g., `/about`, `/contact`)
13+
- Routes with search parameters that have default values
14+
- Routes that don't require dynamic data fetching
15+
16+
Routes with path parameters (e.g., `/users/$userId`) are excluded from automatic discovery since they require specific parameter values to be prerendered.
17+
18+
## Manual Page Configuration
19+
20+
TanStack Start can prerender your application to static HTML files, which can then be served to users without having to generate them on the fly. When prerendering is enabled without specifying pages, TanStack Start will automatically discover and prerender all static routes in your application.
21+
22+
To prerender your application, you can add the `prerender` option to your tanstackStart configuration in `vite.config.ts` file:
1123

1224
```ts
1325
// vite.config.ts
@@ -40,13 +52,17 @@ export default defineConfig({
4052
// Delay between retries in milliseconds
4153
retryDelay: 1000,
4254

55+
// Maximum number of redirects to follow during prerendering
56+
redirectCount: 5,
57+
4358
// Callback when page is successfully rendered
4459
onSuccess: ({ page }) => {
4560
console.log(`Rendered ${page.path}!`)
4661
},
4762
},
48-
// Optional configuration for specific pages (without this it will still automatically
49-
// prerender all routes)
63+
// Optional configuration for specific pages
64+
// Note: When pages are not specified, TanStack Start will automatically
65+
// discover and prerender all static routes in your application
5066
pages: [
5167
{
5268
path: '/my-page',

0 commit comments

Comments
 (0)