TanStack / TanStack/router

Start: SSR dehydrated script output contains unnecessary whitespace/newlines

Open
#6,947 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

The inline <script> blocks generated by TanStack Start for SSR dehydration contain unnecessary blank lines and whitespace. Since this output is machine-generated serialization (Seroval streams, router state, etc.) and not user content, it could be minified without any risk of breaking functionality.

Your Example Website or App

https://github.com/canmi21/taki

Steps to Reproduce the Bug or Issue

View the HTML source of any SSR-rendered TanStack Start page. The dehydrated <script> tags contain patterns like:

<script>($R=>{ ... })($R["tsr"]);    
 document.currentScript.remove()</script>
Image

There are blank lines between statements and unnecessary newlines within the Seroval stream constructor output.

Expected behavior

Dehydrated script output should be compact, e.g:

 <script>($R=>{ ... })($R["tsr"]);document.currentScript.remove()</script>
Screenshots or Videos
Image
Platform
  • Router / Start Version: 1.166.11
  • OS: any
  • Browser: any
  • Browser Version: any
  • Bundler: vite
  • Bundler Version: 8.0.0
Additional context

Why this matters

Slightly increases HTML payload size on every SSR response before compression Makes View Source unnecessarily noisy
This is framework-generated serialization, not user-authored content there is no "<pre.>" or whitespace-sensitive context to worry about, so it is safe to strip

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 in an SSR-rendered TanStack Start page and inspect the inline dehydrated <script> blocks in the HTML source. Trace the Seroval stream and router-state output responsible for the blank lines, then verify that the generated script is compact while SSR hydration still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
full-stack, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.