stelt makes managing global state in Svelte ever so slightly more convenient, while keeping the simplicity of Svelte.
Note: This package only works with Svelte 5, due to the usage of runes.
- You have a
resetfunction which can instantly reset the state to its original form. - You don't need to add the
.svelte.tssuffix to files, you can just use.ts. - It works out of the box with any data type, including special reactive types like
SvelteMap. - It's lightweight.
You can declare state like so:
// count.ts
import stelt from "stelt";
const count = stelt(() => 0); // you declare the value inside of a functionAnd you can use it in a component like so:
<p>{count.value}</p>
<button onclick={() => count.value++}>add</button>
<button onclick={() => count.value--}>subtract</button>
<button onclick={() => count.reset()}>reset</button>That's how simple it is!