-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nivo unable to SSR with Next 13+ #2626
Comments
I'm running into the same issue and would love to hear about a fix on this or maybe a workaround without using use client |
Removing contexts from nivo would require quite a rewrite unfortunately. |
So what you are saying @plouc is that Nivo will never support SSR with NextJs? |
@J4v4Scr1pt, what I'm saying is that for now I'm going to wait for proper guidance on how to do it, I guess other libraries will face this issue, so I suppose such guidance will eventually become available. Also this is an open source project, so if someone wants to give it a try, it could happen earlier. |
Ok, do you know how to highlight this issue to them? I would love to contribute to this great library, but feel I lack the proper knowledge to do so. Edit: |
What about the HTTP API ? That can still be used to render charts on the server? Or perhaps upgrade, to communicate with a NextJS backend ? |
Describe/explain the bug
Attempting to render any Nivo charts (including non-responsive and Canvas) without the
use client
directive in Next 13+ results in an error: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
This StackOverflow post captured Next's reasoning for this, but the Next documentation in question has been updated and is no longer present.
https://stackoverflow.com/questions/74311376/using-react-context-with-nextjs13-server-side-components
From my research, it appears that the global wrapping of all Nivo components with
MotionConfigProvider
(irrespective of if the component intends to use transitions/animations) is the cause of this collision with Next 13+.To Reproduce
https://codesandbox.io/p/devbox/issue-example-yswjvy?file=%2Fapp%2Fexample%2Fpage.tsx%3A90%2C11
Expected behavior
Nivo components are SSR compliant with NextJS. The Nivo FAQ https://nivo.rocks/faq/ states that they are SSR compliant, but ensuring that they are compliant with the most popular SSR framework would be very nice.
Additional context
Thanks for looking at this! I understand that conforming to the ever changing requirements of various frameworks can be frustrating, but from my (incredibly) cursory glances, it does appear that we do not need to wrap canvas components in an animation purposed context. My specific use case (static report generation) does indeed require SSR and I cannot bypass with the
use client
directive. Thanks again!The text was updated successfully, but these errors were encountered: