TanStack / TanStack/router

SPA mode server build contains unnecessary SSR code

Open
#5,059 27 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Start

Describe the bug

When running tanstack start in SPA mode, the server build contains SSR code.

Your Example Website or App
Steps to Reproduce the Bug or Issue

Add

spa: {
  enabled: true,
}

to the tanstackStart vite plugin config

Run npm build

The built .output/server contains code that would be used to server side render the application. However this isn't actually used at runtime.

Expected behavior

The built .output/server only contains the code needed to run server functions/api routes, so it is as slim as possible.

Screenshots or Videos

No response

Platform
  • Start Version: 1.131.31
  • OS: macOS
  • Bundler: vite
  • Bundler Version: 7.1.3
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the tanstackStart Vite plugin's spa.enabled option and npm build. Inspect the generated .output/server and trace which SSR code enters the build; done means the server output retains only code needed for server functions and API routes, without unused SSR code.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.