-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Option to hydrate createApi using extraReducers #1120
Comments
Not yet, also this would theoretically need another step of removing any subscriptions coming in from hydration after a while, when all currently rendered components had an option to re-subscribe to relevant data on the client. This is something we will take a look into for the next version of RTK-Query, but not for the first real release. If you do any experimentation, all insights are very welcome since I don't have a lot of experience with SSR and Next. |
I believe swr and react-query both have an |
I also need such kind of thing to persist Websocket channel ID to store
But it don't, so I have to store that ID somewhere and then do
|
Would you mind sharing your working example? I'm looking for the same solution :) |
I would really like some feedback on the hydration support that is being added in #1277 ;) |
#1277 is merged and is available in the 1.7 betas. |
Details
Currently, there is no way in which the state fetched on the server using createApi can be persisted on the client. People who are building Nextjs or any SSR application might need this functionality so that we can fetch the data on the server and then re-use the same data on the client-side as well.
I had raised a similar issue on the Next Redux Wrapper repository and one solution to handle this would be to provide an option to add extraReducers in the createApi function that RTKQ exposes. Using that, it would be possible to do something like the following:
Right now, the only way to persist createApi is to do what @bjoluc suggested:
Is there any recommended approach to resolving this issue?
The text was updated successfully, but these errors were encountered: