TanStackT
TanStack3mo ago
58 replies
dramatic-maroon

Cloudflare Prerendering

I noticed there aren't any specific instructions on Cloudflare prerendering.

When I followed the Cloudflare guide and then enabled prerendering, I got build errors about compatibilityFlags.

I was able to remove the cloudflare() plugin and then use this wrangler.jsonc:

{
    "$schema": "node_modules/wrangler/config-schema.json",
    "name": "tanstack-start-hybrid",
    "compatibility_date": "2025-09-02",
    "compatibility_flags": ["nodejs_compat"],
    "main": "./dist/server/server.js",
    "assets": {
        "directory": "./dist/client"
    },
    "observability": {
        "logs": {
            "enabled": true,
            "head_sampling_rate": 1,
            "invocation_logs": true
        }
    }
}


With prerender: { enabled: true } this seems to work now.

Are there any downsides with this setup, since I've removed the cloudflare plugin from my vite.config.ts?

import tailwindcss from "@tailwindcss/vite"
import { tanstackStart } from "@tanstack/react-start/plugin/vite"
import viteReact from "@vitejs/plugin-react"
import { defineConfig } from "vite"
import devtoolsJson from "vite-plugin-devtools-json"
import viteTsConfigPaths from "vite-tsconfig-paths"

const config = defineConfig({
    plugins: [
        viteTsConfigPaths({
            projects: ["./tsconfig.json"]
        }),
        tailwindcss(),
        tanstackStart({
            prerender: {
                enabled: true
            },
        }),
        viteReact(),
        devtoolsJson()
    ]
})

export default config
Was this page helpful?