HTML & CSS · Senior · Question 16 of 75

What problems does runtime CSS-in-JS (styled-components, Emotion) have with SSR and React Server Components?

Explanation

Runtime CSS-in-JS computes styles during render and injects them into the document: on the server the styles must be collected and inlined into HTML (otherwise you get a flash), and on the client you pay the runtime cost. They rely on React Context, which Server Components lack, so such components must be client components. Alternatives: CSS Modules, Tailwind, zero-runtime solutions (vanilla-extract, Linaria, Panda).

Further reading

Problem with a question

HTML & CSS · Senior · question 16

Test yourself

Take the HTML & CSS · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz