Summary
In this chapter, we learned what Svelte context and Svelte store are.
Although both Svelte context and Svelte store are meant for sharing data across multiple Svelte components, they are designed and used for different reasons.
Svelte context is meant for sharing the same data across all descendant components in the component tree, while Svelte store is meant for sharing reactivity across Svelte components.
Then, we explored the decision matrix on when to use a Svelte context, when to use a Svelte store, and when to use both.
This chapter served as an introduction to the Svelte context and the Svelte store. By now, you should have a good understanding of what they are and how they work, and feel confident in knowing when to use them. As we move forward, we will explore practical use cases that involve Svelte context and Svelte store, allowing you to apply these powerful concepts effectively in real-world scenarios.
In the next chapter, we will dive deeper into...