bjoluc / next-redux-cookie-wrapper

Sync a subset of your Redux state with cookies in Next.js :cookie: :sparkles:
MIT License
114 stars 4 forks source link

Sync client state with cookies #51

Closed AndyW22 closed 1 year ago

AndyW22 commented 1 year ago

Is there any way to sync the client state with the state defined in the cookies? Currently it is only set/updated during SSR.

This could be useful if you wanted to skip fetching certain data that has to be fetched on the client by keeping it in the state and will be already available on page load.

bjoluc commented 1 year ago

Currently it is only set/updated during SSR.

I'd assume that's because you only update state during SSR? next-redux-cookie-wrapper updates the cookies when relevant client state changes – check it out in the demo by clicking the "Increase counter" button :)

AndyW22 commented 1 year ago

Currently it is only set/updated during SSR.

I'd assume that's because you only update state during SSR? next-redux-cookie-wrapper updates the cookies when relevant client state changes – check it out in the demo by clicking the "Increase counter" button :)

I am updating the state client side too, but upon looking again I've realized that the cookie size on load is 3950B and my state updates are setting it above the limit of 4096B so it is not updating. So will need to look into making the cookie a bit smaller. thanks for your help