Server Components Break Runtime CSS-in-JS
What you'll learn: Why React Server Components fundamentally can't work with runtime CSS-in-JS libraries that inject styles on the client.
The Core Problem
React Server Components run only on the server and send rendered HTML to the browser—they never execute JavaScript on the client. Runtime CSS-in-JS libraries like styled-components and Emotion rely on JavaScript running in the browser to:
- Generate unique class names
- Inject
<style>tags into the document head - React to prop changes and update styles dynamically
Since Server Components don't run client-side JavaScript, they can't trigger this style injection. The result? Your components render, but the styles never appear.
Why This Happens
Think of it like trying to paint a picture (inject styles) in a room you're not allowed to enter (the browser). Runtime CSS-in-JS needs to be "in the room" when React renders, but Server Components finish their work on the server and ship static HTML—no JavaScript execution happens client-side for those components.
Libraries like styled-components expect to hook into React's rendering lifecycle in the browser, reading props and generating styles on-the-fly. Server Components skip that entire phase.
What Still Works
Zero-runtime CSS solutions like vanilla-extract work fine because they generate CSS at build time—no browser JavaScript needed. CSS Modules, Tailwind, and plain CSS also work perfectly since they're just static class names.
Key Takeaway: Runtime CSS-in-JS (styled-components, Emotion) is incompatible with Server Components because it requires client-side JavaScript execution to inject styles—something Server Components never do. Prefer zero-runtime or static styling approaches in SSR/RSC environments.