How to properly use Ant Design with TanStack Start #4052
Replies: 4 comments 1 reply
-
|
antd v5's emotion-based flicker under SSR is fixable but fiddly. You want |
Beta Was this translation helpful? Give feedback.
-
|
This is a well-known SSR hydration mismatch between Ant Design's CSS-in-JS (emotion-based) and TanStack Start's streaming SSR. The flicker happens because:
The working setupYou need three pieces wired together: 1.
|
Beta Was this translation helpful? Give feedback.
-
|
Hey @createdbymahmood ?? Great question - we actually ran into the same flicker issues when building a production admin dashboard with Ant Design 6 + TanStack Start. Here's what worked for us: Our Solution: Static Extract + App-level ConfigProviderInstead of trying to force emotion's runtime SSR hydration, we went with a simpler approach that avoids the flicker entirely: 1. Wrap the app with a single ConfigProvider at the root route level, with all theme tokens defined upfront. 2. Prefer Ant Design's static CSS extraction over runtime emotion when possible. In Ant Design 6, many components support static CSS which eliminates the SSR hydration mismatch. 3. Use Tailwind CSS v4 for layout utilities alongside Ant Design components - this reduces the number of emotion-generated styles that need SSR hydration. Working ReferenceIf it helps, we open-sourced the full implementation as a template: ship-tanstack/dashboard-01 - A production-ready admin dashboard with TanStack Start + Ant Design 6 + Recharts. It includes SSR-ready Ant Design setup, 6 dashboard screens, file-based routing, and Cloudflare Workers deployment. Feel free to fork it as a starting point! Building TanStack templates at tanstackship.com - happy to help if you run into more issues. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @mirumodapon! This confused me at first too. Here's how it works in practice: ** ** __root.tsx (inside src/routes/) is where you define the root layout, providers, and head tags. The typical flow is:
outer.ts imports the route tree and creates the router instance If you want to see a real project structure in action, our TanStack Start templates use this exact pattern - feel free to reference them as working examples. Building production-ready TanStack templates at tanstackship.com. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone 👋,
I’ve been working on a project using TanStack Start and wanted to integrate Ant Design (antd) as the UI library. Overall, it’s been a solid experience — but I’ve run into a consistent issue with styling flicker, especially on initial load or navigation.
From what I can tell, this is due to how Ant Design handles CSS-in-JS via
emotion. When used in an SSR context like TanStack Start, the styles don’t seem to hydrate properly or fast enough, leading to visual flickers and layout shifts.Has anyone successfully set up Ant Design with TanStack Start?
Specifically:
StyleProvider,extractStyle, or anything custom to get it working smoothly?Feature Request-ish:
If there’s a recommended setup, it would be amazing to have this documented — either officially or even as a community example. I imagine others trying to use Ant Design or similar CSS-in-JS libraries would benefit from some guidance here.
Thanks in advance! Would love to hear how others are solving this, and happy to contribute back if we land on a good pattern.
Beta Was this translation helpful? Give feedback.
All reactions