Skip to content

Emotion in React Server Components? #2978

@karlhorky

Description

@karlhorky

The problem

I would like to have a Next.js 13 Layout component (eg. RootLayout) that is a Server Component, and have my styling for that layout also stay in Server Components (potentially even in the same app/layout.tsx file). I only want to switch to a Client Component if there is some client-only features I'm using such as useState.

This also aligns with the current guidance (as of Jan 2023) from the Next.js team to just leave everything a server component until you absolutely need a client component.

Proposed solution

It would be great if Emotion would be able to be used in React Server Components (without conversion to a Client Component)

Alternative solutions

  1. Only a subset of Emotion could be supported in React Server Components - eg. the part that is statically extractable / zero-runtime
  2. Use Client Components via 'use client' every time that a page should be styled
  3. Switch to a different styling solution which can be used in React Server Components (eg. CSS Modules)

Additional context

Moved from this other issue about Next.js 13 app/ directory support:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions