Svelte Stores

What are Stores?

Stores are objects that contain values that can change over time. They're perfect for managing state that needs to be shared between components.

1. Writable Stores

Writable stores can be updated from anywhere. They have set and update methods.

Counter Example

Current count: 0

2. Readable Stores

Readable stores can only be set during creation. They're good for values that come from external sources.

Current Time

Time: 2:06:55 AM

This time automatically updates every second using a readable store.

3. Derived Stores

Derived stores depend on other stores and automatically update when their dependencies change.

Time Formatting

The time string above is a derived store based on the time store.

4. Custom Stores

You can create custom stores with additional methods for specific functionality.

Todo List

Next Steps

Now that you understand Svelte stores, check out:

  • Advanced Techniques - Learn about animations, transitions, and more
  • Start building your SaaS application with Svelte and Laravel!