Svelte · Middle · Question 24 of 75
Why is module-level shared state risky in a SvelteKit app?
// state.svelte.js
export const cart = $state({ items: [] });- ✓Correct answer: On the server the module is shared by all requests, so one user's data can leak to another during SSR
- 2Modules can't contain
$state - 3It works only in development
Explanation
Keep per-user state in context created within the component tree, or in the URL, and persist real data in a database.