-
-
Notifications
You must be signed in to change notification settings - Fork 266
Description
Hi,
I'm a Redux maintainer and the author of RTK-Query.
We've had multiple requests to make RTK-Query work with Next SSR, so I've worked something out on how such an integration could be looking (and potentially open up the way for other SSR mechanisms & suspense).
For client-side hydration/integration of the server-side store with the client-side api slice, I've come up with an API where you just register a extractRehydrationInfo
callback in the createApi
options and either return undefined
or in the case of a hydration action the substate that should be rehydrated. I was hoping to be independent of framework implementations that way.
That would then lead to the internal middleware dispatching a RTK-Query-internal "hydrate" action that would then be picked up by the api slice reducer.
Unfortunately, it seems that that in my experiments with next-redux-wrapper, that internal rehydrate action never makes it to the devtools and all of that happens... on the server, not on the client? At least, it happens in the server console, not on the browser console, but I might be reading that wrong.
I'm a bit out of my comfort zone with SSR and have not a lot experience with that stuff, so I might be making some weird rookie mistake here.
Could you maybe take a look at it and give me some feedback?
I would also be very open to any kind of general feedback you can give me.
I have a demo repository on how I would imagine that this would be used with Next and next-redux-wrapper over here: https://github.com/phryneas/ssr-experiments/blob/126262fcce7f8b788df3670dbc061362c65b6b9e/nextjs-blog/lib/pokemonApi.ts
And I'd also be happy for any kind of feedback on the PR where I'm implementing the SSR-specific stuff:
reduxjs/redux-toolkit#1277
I would be very grateful for any kind of help & advice you could offer :)