🌐 AI搜索 & 代理 主页
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: React Router pre-rendering now works on Cloudflare Workers
description: React Router's pre-rendering feature now works on Cloudflare Workers with full access to environment variables and bindings.
products:
- workers
date: 2025-12-22
---

[React Router](https://reactrouter.com) apps on Cloudflare Workers now have experimental support for [pre-rendering](https://reactrouter.com/how-to/pre-rendering#pre-rendering). Pre-rendered routes have full access to environment variables and bindings at build time and are served as [static assets](/workers/static-assets/).

To enable:

```ts title="react-router.config.ts"
import type { Config } from "@react-router/dev";

export default {
future: {
unstable_previewServerPrerendering: true,
},
prerender: true,
} satisfies Config;
```

This feature requires `@react-router/dev` v7.x.y or later. See the [React Router framework guide](/workers/framework-guides/web-apps/react-router/#prerendering) for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,32 @@ As you have direct access to your Worker entry file (`workers/app.ts`), you can
</Details>

<Render file="frameworks-bindings" product="workers" />

## Pre-rendering (Experimental)

You can prerender your application to static HTML files at build time with React Router and serve them as [static assets](/workers/static-assets/). To enable:

```ts title="react-router.config.ts"
import type { Config } from "@react-router/dev";

export default {
future: {
unstable_previewServerPrerendering: true,
},
prerender: true,
} satisfies Config;
```

No additional configuration is needed in your wrangler config file. For more prerender options, see the [React Router documentation](https://reactrouter.com/how-to/pre-rendering#pre-rendering).

:::note

Requires `@react-router/dev` v7.x.y or later.

:::

:::caution

Prerendering runs during the build step and uses your local environment variables, secrets, and bindings storage data. Ensure your local environment is configured correctly, and use [remote bindings](/workers/development-testing/#remote-bindings) to prerender with production data. If using [Workers Builds](/workers/ci-cd/builds/), update your [build settings](/workers/ci-cd/builds/configuration/#build-settings) to include any required environment variables and secrets.

:::
Loading