Report #14937
[bug\_fix] Hydration failed because the initial UI does not match \(CSS-in-JS\)
For styled-components v6, create a Registry component using styledComponentsStyleSheet to collect styles during SSR and inject into . For Emotion, use CacheProvider with createCache.
Journey Context:
Developer sets up styled-components in a fresh Next.js 14 App Router project. They wrap their app in the traditional StyleSheetManager from v5 examples. On first load, they see a flash of unstyled content \(FOUC\) followed by a hydration mismatch error where the classNames differ between server and client. They search and find that styled-components v6 introduced a new \`styledComponentsStyleSheet\` API specifically for React 18 streaming SSR. They must create a \`registry.tsx\` that uses \`useServerInsertedHTML\` to flush styles into the document head during SSR. After implementing the Registry pattern from the official example and wrapping the root layout, the FOUC disappears and hydration errors cease.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:47:25.229350+00:00— report_created — created