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
title: Static prerendering support for TanStack Start
3
+
description: TanStack Start apps can now prerender routes to static HTML at build time using the Cloudflare Vite plugin.
4
+
products:
5
+
- workers
6
+
date: 2025-12-19
7
+
---
8
+
9
+
[TanStack Start](https://tanstack.com/start/) apps can now prerender routes to static HTML at build time with access to build time environment variables
10
+
and bindings, and serve them as [static assets](/workers/static-assets/). To enable prerendering, configure the `prerender` option of the TanStack Start plugin in your Vite config:
This feature requires `@tanstack/react-start` v1.138.0 or later. See the [TanStack Start framework guide](/workers/framework-guides/web-apps/tanstack-start/#static-prerendering) for more details.
Copy file name to clipboardExpand all lines: src/content/docs/workers/framework-guides/web-apps/tanstack-start.mdx
+65-22Lines changed: 65 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,29 +20,21 @@ import {
20
20
21
21
[TanStack Start](https://tanstack.com/start) is a full-stack framework for building web applications. It comes with features like server-side rendering, streaming, server functions, bundling, and more. In this guide, you learn to deploy a TanStack Start application to Cloudflare Workers.
22
22
23
-
## 1. Set up a TanStack Start project
23
+
## Creating a new TanStack Start application
24
24
25
-
If you have an existing TanStack Start application, skip to the [Configuring an existing TanStack Start application](#configuring-an-existing-tanstack-start-application) section.
26
-
27
-
### Creating a new TanStack Start application
28
-
29
-
Use the [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) CLI (C3) to set up a new project. C3 will create a new project directory, initiate TanStack Start's official setup tool, and provide the option to deploy instantly.
30
-
31
-
To use `create-cloudflare` to create a new TanStack Start project with Workers Assets, run the following command:
25
+
To create a TanStack Start application, run the following command:
After setting up your project, change your directory by running the following command:
33
+
After you have created your project, run the following command in the project directory to start a local development server. This will allow you to preview your project locally during development.
40
34
41
-
```sh
42
-
cd my-tanstack-start-app
43
-
```
35
+
<PackageManagerstype="run"args="dev" />
44
36
45
-
###Configuring an existing TanStack Start application
37
+
## Configuring an existing TanStack Start application
46
38
47
39
If you have an existing TanStack Start application, you can configure it to run on Cloudflare Workers by following these steps:
48
40
@@ -93,13 +85,7 @@ If you have an existing TanStack Start application, you can configure it to run
93
85
94
86
</Steps>
95
87
96
-
## 2. Develop locally
97
-
98
-
After you have created your project, run the following command in the project directory to start a local development server. This will allow you to preview your project locally during development.
99
-
100
-
<PackageManagerstype="run"args="dev" />
101
-
102
-
## 3. Deploy your Project
88
+
## Deploy your Project
103
89
104
90
You can deploy your project to a `*.workers.dev` subdomain or a [Custom Domain](/workers/configuration/routing/custom-domains/) from your own machine or from any CI/CD system, including Cloudflare's own [Workers Builds](/workers/ci-cd/builds/).
105
91
@@ -116,8 +102,6 @@ This can help you making sure that your application will work as intended once i
116
102
117
103
:::
118
104
119
-
---
120
-
121
105
## Bindings
122
106
123
107
Your TanStack Start application can be fully integrated with the Cloudflare Developer Platform, in both local development and in production, by using bindings.
@@ -157,3 +141,62 @@ Will populate the `env` object with the various bindings based on your configura
No additional configuration is needed in your wrangler config file. For more prerender options, see the [TanStack Start documentation](https://tanstack.com/start/latest/docs/framework/react/guide/static-prerendering).
169
+
170
+
:::note
171
+
172
+
Requires `@tanstack/react-start` v1.138.0 or later.
173
+
174
+
:::
175
+
176
+
:::caution
177
+
178
+
Prerendering runs during the build step and uses your local environment variables, secrets, and bindings storage data. Ensure your build environment is configured correctly, and use [remote bindings](/workers/development-testing/#remote-bindings) to prerender with production data.
179
+
180
+
:::
181
+
182
+
### Prerendering in CI environments
183
+
184
+
When prerendering in CI, your Worker code may need access to environment variables or secrets that are not available in the build environment. One way to handle this is to include a `.env` file with variable references, which resolve to values provided by your CI environment:
185
+
186
+
```sh title=".env"
187
+
API_KEY=${API_KEY}
188
+
DATABASE_URL=${DATABASE_URL}
189
+
```
190
+
191
+
In your CI environment, set `CLOUDFLARE_INCLUDE_PROCESS_ENV=true` and provide the required values as environment variables. If using [Workers Builds](/workers/ci-cd/builds/), update your [build settings](/workers/ci-cd/builds/configuration/#build-settings) accordingly.
192
+
193
+
:::note
194
+
195
+
For local development, create a `.env.local` file with actual secret values. Do not commit this file to your repository. Values in `.env.local` override the references in `.env`:
0 commit comments