You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/start/framework/react/guide/static-prerendering.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,21 @@ title: Static Prerendering
5
5
6
6
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.
7
7
8
-
## Prerendering
8
+
## Automatic Static Route Discovery
9
9
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:
11
23
12
24
```ts
13
25
// vite.config.ts
@@ -40,13 +52,17 @@ export default defineConfig({
40
52
// Delay between retries in milliseconds
41
53
retryDelay: 1000,
42
54
55
+
// Maximum number of redirects to follow during prerendering
56
+
redirectCount: 5,
57
+
43
58
// Callback when page is successfully rendered
44
59
onSuccess: ({ page }) => {
45
60
console.log(`Rendered ${page.path}!`)
46
61
},
47
62
},
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
0 commit comments