Skip to content
Source
Sign inSign up
TanStack/router

Start + Rsbuild: SPA mode dev server SSRs routes and runs loaders on the server #8543

Send to my agent
Closedglekner(GitHub profile, opens in a new tab) opened this issue 0 comments

With spa: { enabled: true }, rsbuild dev server-renders the matched route and runs its loader on the server. vite dev returns only the shell.

Repro

// rsbuild.config.ts
export default defineConfig({
  plugins: [pluginReact(), tanstackStart({ spa: { enabled: true } })],
})
// src/routes/index.tsx
export const Route = createFileRoute('/')({
  loader: () => (typeof window === 'undefined' ? 'server' : 'client'),
  component: () => <p>loader ran on the {Route.useLoaderData()}</p>,
})

Run rsbuild dev, then curl localhost:3000/.

Expected

Shell only (no route markup), with the loader running on the client, same as vite dev.

Actual

The response contains <p>loader ran on the <!-- -->server</p>.

Possible fix

The Vite plugin defines TSS_SHELL in serve mode (vite/planning.ts#L154-L156). The Rsbuild source.define block (rsbuild/plugin.ts#L205-L246) doesn't, so IS_SHELL_ENV in createStartHandler.ts is always false. Adding process.env.TSS_SHELL / import.meta.env.TSS_SHELL there when isDev fixes it. If #8137 lands first, the key also belongs in its enforcedDefineConfig.

Workaround

In dev, set environments.ssr.source.define to { 'process.env.TSS_SHELL': '"true"', 'import.meta.env.TSS_SHELL': '"true"' }.

Versions

@tanstack/react-start 1.168.59 (start-plugin-core 1.171.48), @rsbuild/core 2.2.10, Node 24.16. Still present on main at 41ebd28.

Sign in to join this conversation.