Supported libraries
The following libraries are known to work with the App Router Client Components:styled-components
Tagged template literal API with full theming support.
Emotion
High-performance CSS-in-JS library with
css prop and styled API.Kuma UI
Zero-runtime utility-first CSS-in-JS.
vanilla-extract
Type-safe, zero-runtime CSS-in-JS.
styled-components
Installation
- npm
- pnpm
- yarn
Configuration
Enable styled-components innext.config.js to activate the built-in Babel plugin for server-side rendering:
next.config.js
Registry
To use styled-components with the App Router, you need to set up a client-side style registry. This collects styles generated during a render and flushes them into the<head> of the document.
lib/registry.tsx
app/layout.tsx
Usage
Use styled-components only in Client Components:app/components/Button.tsx
Emotion
Installation
- npm
- pnpm
- yarn
Registry
Emotion requires a similar server-side registry to styled-components:lib/registry.tsx
Usage
Use Emotion in Client Components:app/components/Card.tsx
Server Components
CSS-in-JS libraries that depend on runtime style injection cannot be used in Server Components. For Server Components, use:- CSS Modules — zero runtime, statically extracted at build time.
- Tailwind CSS — utility classes with no JavaScript runtime.
- Sass — pre-processed CSS compiled at build time.
