Is context provider in SSR mode necessary? #87
-
Since pullstate implements an alternative to the context API, is there a way to avoid using it in SSR? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you are manipulating the state during the rendering on the server-side and need to hydrate that state on the client side (which is generally always the case) - then there is no other way to go about it than using context. Any library which does SSR and is manipulated during a render needs to have context- there's no way around it, because each separate user "request" on a server needs to maintain a unique state, which can't be controlled globally like we do on the client (otherwise all requests share the same state and clash / overwrite each other)- hence context is required. If you are not manipulating the state during rendering on the server, then you don't need the context provider. But I'd recommend just putting it in anyway because you might run into weird issues in the future. |
Beta Was this translation helpful? Give feedback.
If you are manipulating the state during the rendering on the server-side and need to hydrate that state on the client side (which is generally always the case) - then there is no other way to go about it than using context.
Any library which does SSR and is manipulated during a render needs to have context- there's no way around it, because each separate user "request" on a server needs to maintain a unique state, which can't be controlled globally like we do on the client (otherwise all requests share the same state and clash / overwrite each other)- hence context is required.
If you are not manipulating the state during rendering on the server, then you don't need the context provider.…