Installation
Requirements
| Environment | Minimum version |
|---|---|
| Node.js | 18+ |
| Vue | 3.3.0+ (optional — only for the package root / Vue composables) |
| React | 18.0.0+ (optional — only for /react) |
pinia | 2.0.0+ or 3.0.0+ (optional — only for /pinia) |
@nuxt/kit | 3.0.0+ (optional — only for the /nuxt module) |
h3 | 1.0.0+ (optional — only for the Nuxt module's SSR-aware useCookie) |
Installation
bash
npm install vue-storage-kitFor Vue, install Vue itself (optional peer — only needed if you import from the package root or any Vue-specific composable):
bash
npm install vue@>=3.3For React (vue-storage-kit/react), install React instead — you don't need vue at all:
bash
npm install react@>=18Quick start
vue
<script setup lang="ts">
import { useLocalStorage } from 'vue-storage-kit'
const { value: theme } = useLocalStorage('theme', 'light')
</script>
<template>
<button @click="theme = theme === 'light' ? 'dark' : 'light'">Current theme: {{ theme }}</button>
</template>The value is persisted to localStorage and is reactive — changing theme.value writes to storage immediately.