Skip to content
Source
Sign inSign up
TanStack/router

docs(router): clarify static title fallback and trade-offs in SPA mode #8873

OpenRohan-Dedhia(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8873/headopened

Showing 1 changed file with 5 additions and 1 deletion.

x
0 of 1 viewed, 1 left
5 additions and 1 deletiondocs/router/guide/document-head-management.mdModified
View file
@@ -132,7 +132,11 @@
​
### Single-Page Applications
​
-First, remove the `<title>` tag from the index.html if you have set any.
+In single-page applications, the initial HTML shell is static and identical across all routes before JavaScript executes. When using `<HeadContent />` in SPA mode:
+​
+- Remove the static `<title>` tag from `index.html` to avoid duplicate title tags. `<HeadContent />` dynamically injects and manages `<title>` elements at runtime, but does not adopt or replace existing unmanaged `<title>` tags from the initial HTML document.
+- If your application strictly requires route-specific metadata or titles in the raw initial HTML response (for search engines or social media crawlers), consider using [TanStack Start](../../start/framework/react/overview.md) or static prerendering instead of client-only SPA rendering.
+- For a default title fallback in SPA mode, declare a baseline title on the root route's `head` option (`head: () => ({ meta: [{ title: 'My Default Title' }] })`). Child routes will automatically override it when loaded.
​
<!-- ::start:framework -->
​