#Redux in Next js 13.4
15 messages · Page 1 of 1 (latest)
after wrapping up layout with provider, still pages are rendered on client side
@cobalt snow is there any other way?
how do you know? That should not ahppen
The big problem here is causing for client global redux state to be on the server. Usually this is accomplished by loading some amount of defaut or database data server side, applying it to a redux store, then shipping the store state to the client as serverside/initial props. Then client side code MUST hydrate first with the redux state sent by the server. After to reconcile client side stuff, in useEffect, you add a redux action that takes saved/inferred client side state.
There will be a flash of info change for anything the server didnt have.
Serializing client state hints to query parameters or cookies can help too.
@rapid charm any example or repo for this?
It really depends on what you are trying to do, there is not a one size fits all thing.
This is a major weakness of redux
I want to manage the global state with redux without client side rendering
You will need to describe what you are actually trying to accomplish because, from the things you have said so far, Redux doesn't make that much sense.
Are you trying to manage state that is not per-user but is global to the entire application for all users to share?
I want to manage the global state with redux without client side rendering
redux handles client-side states, which are not applicable to the server. Hence it is not applicable to server components. What you are trying to do is impossible. For details on how to do data-fetching in server components, read https://nextjs.org/docs/app/building-your-application/data-fetching
You are replying to the wrong person 👍