Sveltinia stores for Svelte and SvelteKit.
Typed stores, persistence, plugins, action hooks, mutation subscriptions, request-safe SSR.
Sveltinia is a Svelte 5 state management library inspired by Pinia. It provides typed stores for Svelte and SvelteKit, persisted Svelte stores, action hooks, mutation subscriptions, plugins, and request-safe SvelteKit SSR state management.
Use it when you want a Pinia alternative for Svelte, familiar SvelteKit Pinia-style ergonomics, or a small store API without a framework-sized abstraction.
Install it with whichever package manager your project already uses:
npm install sveltinia
# or: yarn add sveltinia
# or: pnpm add sveltinia
# or: bun add sveltiniaimport { createSveltinia, defineStore } from 'sveltinia'
export const sveltinia = createSveltinia({ debug: import.meta.env.DEV })
export const useCounter = defineStore('counter', {
state: () => ({ count: 0 }),
getters: { double: (state) => state.count * 2 },
actions: { increment() { this.count++ } },
persist: true
})Install first-party plugins once per root:
import { createDebugPlugin, createPersistedState } from 'sveltinia'
sveltinia.use(createDebugPlugin()).use(createPersistedState())Use the store in application code:
const counter = useCounter(sveltinia)
counter.increment()
console.log(counter.double)In a Svelte component, adapt it to a Svelte readable store:
<script lang="ts">
import { useStore } from 'sveltinia/svelte'
import { fromStore } from 'svelte/store'
import { useCounter } from '$lib/stores/counter'
const counter = fromStore(useStore(useCounter()))
</script>
<button onclick={() => counter.current.increment()}>{counter.current.count}</button>yarn publish:dry
yarn publish:npmUpdate packages/sveltinia/package.json before publishing. Published npm versions are immutable.
Built and maintained by dene-.