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

What happens if we store subtrees in cookie whose size exceeds 4096 bytes ? #46

Closed phatify closed 1 year ago

phatify commented 1 year ago

what happens if we store subtrees in cookie whose size exceeds 4096 bytes ? Is that an efficient way to persist state?

image

bjoluc commented 1 year ago

what happens if we store subtrees in cookie whose size exceeds 4096 bytes ?

I don't know how browsers handle this in particular, but chances are something will go wrong when saving the cookie...

Is that an efficient way to persist state?

For large amounts of state, you should consider using Redux Persist. You could technically split large subtrees into multiple cookies, but that doesn't make cookies any more efficient. Alternatively, if you can infer pieces of your state (for instance by loading them from a database), it may be an option to sync relevant state portions with cookies and just dynamically fetch missing pieces.