Reactive state for URL and storage in Vue. Type-safe, with the source always in charge.
Documentation lives at usewagen.dev.
pnpm add usewagenvue is a peer dependency. vue-router is only needed if you use the router composables.
import { parseAsInteger } from 'usewagen'
import { useRouteState } from 'usewagen/router'
import { useLocalStorage } from 'usewagen/storage'
const page = useRouteState({ key: 'page', parser: parseAsInteger.withDefault(1) })
const theme = useLocalStorage({ key: 'theme' })page is a Ref<number> over ?page= and theme a Ref<string | null> over the theme
entry in localStorage.