Migration Path: When to Consider Alternatives
You'll learn when and why the React ecosystem is shifting away from runtime CSS-in-JS libraries like styled-components and Emotion.
The Modern Context
Runtime CSS-in-JS libraries were revolutionary for component-scoped, dynamic styling. But the landscape has changed dramatically with React Server Components (RSC). Since RSCs run on the server without a client-side JavaScript bundle, they're fundamentally incompatible with runtime style injection—styled-components and Emotion can't parse styles during server rendering in the new paradigm.
Even in client-only apps, runtime CSS-in-JS carries performance costs you've learned about: parsing styles on every render, injecting <style> tags into the DOM, and recalculating specificity. For highly dynamic UIs, this overhead becomes noticeable.
When to Consider Moving
Immediate red flags:
- You're adopting Next.js 13+ App Router or another RSC framework
- You're experiencing performance bottlenecks during style recalculation
- Your bundle size has grown significantly from CSS-in-JS runtime code
Migration paths:
- Tailwind CSS: Zero runtime, utility-first approach retains component colocation without the parsing cost. Trade dynamic prop-based styling for conditional class composition.
- vanilla-extract: Zero-runtime CSS-in-JS with TypeScript support. Styles compile to static CSS at build time, giving you type safety without client overhead.
- CSS Modules: Classic, proven, zero-runtime. Less dynamic but battle-tested.
You don't have to migrate existing projects—runtime CSS-in-JS still works in client components. But for new projects, especially with RSC, build-time solutions are now the pragmatic default.
Key Takeaway: Runtime CSS-in-JS is incompatible with React Server Components and carries performance costs; modern alternatives like Tailwind and vanilla-extract offer zero-runtime styling with better RSC compatibility.