Server Rendering
Advanced SSR, hydration, and client-only rendering in Tamagui
Tamagui renders responsive styles and animation state on the server so the first client frame can hydrate without flickering.
How it works
Tamagui renders in three phases:
- Server: Renders with proper CSS media queries for everything, including components using spring animation drivers (which normally require hard-coded values)
- Client (first render): Renders with CSS to match the server output perfectly
- Client (after hydration): Seamlessly swaps to springs and animations
Hydration matches the server output without flickering, even for responsive layouts with animations.
Opting out
You can opt out of SSR entirely or for specific parts of your app.
Wholesale: disableSSR
For single-page applications that don’t need SSR, disable it entirely in your config:
When disableSSR is true:
- Media queries immediately use actual values
- No double render occurs
- Your entire app is wrapped with
<ClientOnly enabled>
Partial: ClientOnly component
For fine-grained control, wrap specific parts of your tree:
Configuration component
The Configuration component is essentially a shorthand for ClientOnly. It accepts configuration settings like disableSSR:
useMedia and SSR
The useMedia hook automatically leverages Tamagui’s smart SSR rendering. During server render, it returns appropriate defaults that match CSS media queries, then updates after hydration without flickering.
SSR hooks
useDidFinishSSR
Returns true when hydration is complete:
Behavior:
- Server/before hydration:
false - After hydration:
true - Inside
<ClientOnly enabled>: alwaystrue
useIsClientOnly
Checks if you’re in a client-only context:
useClientValue
Returns undefined during SSR, your value after hydration:
Best practices
When to use disableSSR
Use it for:
- Single-page applications
- Client-only web apps
- Maximum performance without SSR overhead
Avoid for:
- SEO-critical content
- Server-rendered frameworks (Next.js SSR/SSG)
- Fast initial page loads
When to use ClientOnly
Use it for:
- Expensive client-only components (charts, editors)
- Browser API dependencies
- Non-critical UI that can load after initial render
Example:
When to use hooks
useDidFinishSSR: Conditional rendering based on hydration stateuseIsClientOnly: Checking client-only context for browser APIsuseClientValue: Shorthand for client-only values
Package reference
See also
- Configuration: learn more about settings
- useMedia: responsive media queries
- Themes: theme system and context