Vue · Senior · Question 58 of 75
Why use Nuxt's useState instead of a module-level ref for shared state?
- ✓Correct answer:
useStateis scoped per request on the server and serialized to the client; a module-level ref is shared across all users on the server - 2
useStateis faster - 3Module-level refs aren't reactive
Explanation
Module-level state is a classic cross-request leak in SSR. Pinia with Nuxt is also request-scoped.