Tiny serializable web storage library. Support localStorage
and sessionStorage
.
- Automatic serialization and deserialization
- Type-safe
npm i @tiny-libs/storage
import { useLocalStorage } from '@tiny-libs/storage'
const storage = useLocalStorage('key', {})
storage.set({ hello: 'hi', greeting: 'hello' })
const obj = storage.get()
console.log(obj.greeting) // 'hello'
import { useSessionStorage } from '@tiny-libs/storage'
const storage = useSessionStorage('key', 1)
console.log(storage.get()) // 1
storage.set(2)
storage.set(null) // clear storage
console.log(storage.get()) // 1
MIT copyright © 2024-present alex wei