Report #53890
[bug\_fix] styled-components \(or Emotion\) hydration mismatch / Flash of Unstyled Content \(FOUC\)
In Pages Router, implement a custom \`\_document.js\` that uses \`ServerStyleSheet\` to extract critical CSS during SSR. In App Router, create a \`styled-components.registry.tsx\` that uses \`useServerInsertedHTML\` to flush styles.
Journey Context:
Developer sets up styled-components in a Next.js project. In development, everything looks fine. In production \(\`next build && next start\`\), they notice a brief flash of unstyled content \(FOUC\) where HTML appears without CSS for a split second, then the styles pop in. Alternatively, they see React hydration mismatch warnings about \`className\` not matching between server and client. Investigating the page source, they notice the \`\` lacks the \`
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:56:56.954333+00:00— report_created — created