Usage
Signature
A readable or writable store to get the value from.
The current value of the store.
When to use get()
Useget() when you need to read a store value outside of Svelte’s reactive context:
- In event handlers where you need the current value but don’t want to reactively track it
- In regular JavaScript/TypeScript modules (not components)
- When you need a one-time snapshot of the value
- In server-side code or utility functions
$ prefix for auto-subscription, which keeps your component reactive:
Examples
In event handlers
In utility functions
Conditional logic
Derived stores with get()
Server-side usage
Comparing values
Avoid overuse
Whileget() is useful, avoid overusing it in Svelte components. The $ prefix provides automatic subscription management: