Use @emotion/server for SSR
mainThe @emotion/server package provides three primary APIs for server-side rendering (SSR) workflows. These APIs allow you to extract critical CSS from your rendered components and inline that CSS into your HTML to prevent layout shifts and improve performance.
The three available patterns are:
- Extract critical CSS: Identify the styles required for the current render.
- Inline critical CSS to a string: Inject the extracted styles directly into an HTML string.
- Inline critical CSS to a stream: Inject styles into an HTML stream for progressive rendering.
For detailed API signatures and implementation guides, refer to the official SSR documentation.