Nuxt useState vs ref(): Why Server State Leaks Across Users
6.7 relevance
Score Breakdown
technical depth 8
novelty 6
actionability 8
community 5
strategic 4
personal 6
Scored daily by a customisable AI persona to surface the most relevant engineering leadership news.
Nuxt.js state management bug fix; relevant to serverless but narrow framework focus.
Summary
Nuxt's `ref()` declared at module scope in composables creates a singleton that gets shared across all server-side requests, causing user-specific data like cart contents to leak between users under concurrent traffic. The fix is `useState()`, which isolates state per request via a unique key and ensures it's only hydrated on the client. The same danger exists in Nitro server routes, where `event.context` should be used instead of module-scoped variables.