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: [] });

Explanation

Keep per-user state in context created within the component tree, or in the URL, and persist real data in a database.

Further reading

Problem with a question

Svelte · Middle · question 24

Test yourself

Take the Svelte · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz