Skip to content

Installation

Requirements

EnvironmentMinimum version
Node.js18+
Vue3.3.0+ (optional — only for the package root / Vue composables)
React18.0.0+ (optional — only for /react)
pinia2.0.0+ or 3.0.0+ (optional — only for /pinia)
@nuxt/kit3.0.0+ (optional — only for the /nuxt module)
h31.0.0+ (optional — only for the Nuxt module's SSR-aware useCookie)

Installation

bash
npm install vue-storage-kit

For 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.3

For React (vue-storage-kit/react), install React instead — you don't need vue at all:

bash
npm install react@>=18

Quick 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.