TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published


npm: @feltcoop/svelte-gettable-stores

This library can cause tricky bugs and there may be good reasons the Svelte team supports get and not .get(). (some discussion on this issue) Please do not use this unless you really truly know what you're doing 🤒 The only benefit is performance, which may not be relevant for your usage.

Adds a non-reactive .get() to Svelte stores (as well as @feltcoop/svelte-mutable-store). It copypastes the original implementations and makes these changes.

See the tests for more. The implementation was partially inspired by svelte-store2. Discussion is welcome in issues and privately.


Svelte offers the standalone get function to non-reactively access store values, but it costs more than necessary in most cases. From the Svelte docs:

"This works by creating a subscription, reading the value, then unsubscribing. It's therefore not recommended in hot code paths." (svelte.dev/docs)

In many cases, this cost is either negligible or architecturally irrelevant. In other cases, like nested stores and collections processed in non-reactive contexts like event handlers, the cost can be undesirably high. (we can provide open source examples, open an issue if you'd like to discuss)

This library adds .get() to the original store implementations to access values without the cost of a subscription+unsubscription in all cases except derived stores with zero subscribers. In that case, it uses the get builtin.


MIT (copy of Svelte's license)

everything else: Unlicense (public domain)




DownloadsWeekly Downloads






Unpacked Size

27.7 kB

Total Files


Last publish


  • ryanatkn
  • greatbacon