Skip to content

wobsoriano/sveltio

Repository files navigation

sveltio

npm (tag) npm bundle size NPM

State management solution for Svelte using proxies. Powered by valtio.

Installation

pnpm add valtio sveltio

Usage

// store.ts
import { proxy } from 'sveltio'

export const state = proxy({ count: 0 })

Read from snapshots, mutate the source.

<script lang="ts">
  import { useSnapshot } from 'sveltio'
  import { state } from './store'
  const snap = useSnapshot(state)
</script>

<button on:click={() => state.count++}>
  Clicks: {$snap.count}
</button>

For more info on how to use valtio, check out the official docs.

License

MIT