Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

useStorage API

API reference for the useStorage composable.

Explore these related pages for additional context and usage patterns.

PageCategory
useStoragePlugins
useHydrationPlugins
PluginsFundamentals

Functions

createStorage

(options?: StorageOptions) => E

Creates a new storage instance.

createStorageContext

<_E>(_options?: StorageContextOptions | undefined) => ContextTrinity<_E>

createStoragePlugin

(_options?: StorageContextOptions | undefined) => Plugin

useStorage

<_E>(namespace?: string) => _E

Options

adapter

StorageAdapter | undefined

The storage adapter to use. Defaults to localStorage in browser, MemoryStorageAdapter otherwise

prefix

string | undefined

The prefix to use for all storage keys. Defaults to 'v0:'

serializer

{ read: (value: string) => unknown; write: (value: unknown) => string; } | undefined

Custom serializer for reading and writing values. Defaults to JSON.parse/stringify

ttl

number | undefined

Time-to-live in milliseconds. When set, expired entries return the default value on `get()` and `set()` automatically timestamps entries.

Methods

has

(key: string) => boolean

Check if a key exists in storage

get

<T>(key: string, defaultValue?: T) => Ref<T>

Get a reactive ref for a storage key

set

<T>(key: string, value: T) => void

Set a value for a storage key

remove

(key: string) => void

Remove a key from storage

clear

() => void

Clear all keys from storage

Was this page helpful?

Ctrl+/