-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[SSR] Recoil doesn't work server side with Next.js 13 #2082
Comments
same here |
It works for me if i use "use client at top" but doesn't work when i use server components can anyone explain If i use "use client" in layout.js does it means the child components will be rendered in client |
same for me :( |
Just finished migrating one of my projects to 13. This is what I found:
All work is the same as Next12 on my side except for some non-Recoil-related errors, such as some 'Modules are not found.' This is a known issue, I believe. Next13's app directory is far from ready to use, and I will skip using it until it becomes stable. |
Upon further investigation, the issue appears to be specific to using the |
I've pinpointed the issue I believe to the usage of Nextjs appears to use the ReactDOMServerRenderingStub during SSR which does not export the Is that batchedUpdates function needed during SSR for Recoil? With React 18+, I believe all When I remove the |
same here in SSG |
…g SSR (facebookexperimental#2086) Summary: Resolves facebookexperimental#2082 Pull Request resolved: facebookexperimental#2086 Reviewed By: wd-fb Differential Revision: D41054948 Pulled By: drarmstr fbshipit-source-id: eb421deb5a84e9ff9390a1a8d88b28c720765cb1
@drarmstr Any estimate on when this change will be released in a new NPM version? |
Any news about not being able to initialize Recoil with data obtained in SSR in Next.js 13? |
@drarmstr would you be able to help make a release that includes this fix? Still blocked by this. Or is there someone else who can help? Thank you! |
Another vote for a release... |
Has this project died or something? There hasn't been a new version released since October of last year. I know Facebook had layoffs but I didn't realize they laid off the entire team behind Recoil... |
Any updates on this? Same Issues |
Same for me. Does it mean that the component has a head line with |
for this issue, I ended up manually waiting the client ready before rendering from recoil state, I did this because the content I was rendering is not required to be SSR |
…g SSR (#2086) Summary: Resolves facebookexperimental/Recoil#2082 Pull Request resolved: facebookexperimental/Recoil#2086 Reviewed By: wd-fb Differential Revision: D41054948 Pulled By: drarmstr fbshipit-source-id: eb421deb5a84e9ff9390a1a8d88b28c720765cb1
The issue due to facebookexperimental/Recoil#2082
any news ? |
then why should we use Nextjs if we shall end up turning everything into a client component? |
Fixed with #2086 and released with |
This is not an issue. The way that Next.js works is server-side first. You can't just wrap the app in the
layout.tsx file should look like this:
By doing this we put the Recoil provider on the client (browser) and anything that is not marked with "use client" will be rendered as server side. You can not add "use client" to the layout.tsx or layout.js, page.tsx or page.js files |
Although this might work as a hack there are some files or compomponents you want server-side so wont this wrapper essentially put all those {children} in the clientside in your layout.tsx file |
@MattSteedman Nope even if you put it as a wrapper any child components will still be server unless you use "use client" in each component. This is not a hack or workaround. Recoil is state management tools and anything that use state must be rendered on the client. |
facebookexperimental/Recoil#2082 (comment) recoil과 ssr 충돌 해결
Hi, There is another issue happening because of SSR If I want to use the effects property, even though I specify 'use client' in the component I wrap in
Is there a solution for this, or is there a PR about it?
It should be noted that in (RootLayout) layout.tsx I do not use 'use client' because I use a server function:
There is no recoil component on the layout.tsx page |
Is there any way to share recoil state across multiple recoil roots? This suggests no:
https://recoiljs.org/docs/api-reference/core/RecoilRoot/ Does this mean recoil state can only apply to a single client subtree of a next app? My use case is that I have a SSR app, with different tree nodes rendered on client using the 'use client' directive.
Where child components A and C are client components. Is it possible to share recoil state between A and C? it seems like that could theoretically work - they are both in the same browser process after all.... (this seems like a pretty common use case for state - updating a navigation sidebar if a item is consumed / interacted, or a shopping cart count, etc....) |
…g SSR (#2086) Summary: Resolves facebookexperimental/Recoil#2082 Pull Request resolved: facebookexperimental/Recoil#2086 Reviewed By: wd-fb Differential Revision: D41054948 Pulled By: drarmstr fbshipit-source-id: eb421deb5a84e9ff9390a1a8d88b28c720765cb1
The Gist
When using Recoil + Next.js 13, I'm encountering an error while pre-rendering the page server side. The app works as expected client side though so no issue there, just when Recoil is used during server side pre-render.
The Error
The Environment
The Code
The text was updated successfully, but these errors were encountered: