This repository demonstrates a bug in @tanstack/react-start's createIsomorphicFn when used with Cloudflare Workers.
When createIsomorphicFn() is called at module top-level, it returns a function instead of the expected value. However, when called inside a component, it works correctly.
Related issue: TanStack/router#6217
const getEnvironment = createIsomorphicFn()
.server(() => "server")
.client(() => "client");
const value = getEnvironment();
// Expected: "server" during SSR, "client" on client
// Actual: [Function] at module level- Clone this repository
- Install dependencies:
pnpm install
- Start dev server:
pnpm dev
- Open http://localhost:5173
- Observe the console output and page content
| Call Location | Expected | Actual |
|---|---|---|
| Module top-level | "server" (string) |
[Function] |
| Inside component | "client" (string) |
"client" ✅ |
@tanstack/react-start: 1.143.6@cloudflare/vite-plugin: 1.0.0+- Vite: 7.0.0
- Node.js: 22.x