Skip to content

Do createGlobalState and createSharedComposable have issues with cross-request state pollution on Nuxt SSR? #3011

Closed Answered by Tofandel
dev-abota asked this question in Q&A
Discussion options

You must be logged in to vote

They are indeed susceptible to cross request state pollution and are not SSR safe, they are quite simple composable and just keep a global state and share it across all vue instances (it's in the definition) so if in SSR you have multiple vue instances at the same time, since they keep the same reference to a single state, this single state is shared across requests. It might not show up in testing if multiple render never happen in parallel because the state is disposed of when there is no more vue instance. So be careful and only use those on the client.

To make those methods SSR safe, the global state would have to be stored within a single app context (meaning you would need to pass i…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ilyaliao
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants