You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An issue arises when using Emotion with Next.js 15.1.6, where the application unexpectedly crashes in development mode (npm run dev) due to Emotion seemingly being invoked in server components, despite being used only within a client wrapper.
An issue arises when using Emotion with Next.js 15.1.6, where the application unexpectedly crashes in development mode (npm run dev) due to Emotion seemingly being invoked in server components, despite being used only within a client wrapper.
TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it.
Read more: https://nextjs.org/docs/messages/context-in-server-component
The stack trace suggests that Emotion is causing the issue even in components where it is not directly imported.
Reproduction Steps
git clone: https://github.com/nokia1054g/EmotionNextBug
npm run dev
In open Words:
Create a Next.js 15.1.6 project with Emotion.
Use Emotion within a page.tsx client wrapper component.
Run npm run dev, and observe the application crash on refresh.
Marking everything as a client component resolves the error but disrupts server component usage.
Expected Behavior
Server components should not be affected by Emotion usage within a client wrapper.
The app should not require marking layout.tsx and page.tsx as client components.
Actual Behavior
The app crashes when running in dev mode, claiming that createContext must be used in client components.
The issue disappears when marking server components as client components, but this breaks the expected Next.js architecture.
The text was updated successfully, but these errors were encountered: