keyv-browser

Handles browser-specific persistence using `localStorage` or `IndexedDB` via the Keyv API. Use this for web-based caching, handling storage quotas, and implementing asynchronous field-based accessors in the browser.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "keyv-browser" with this command: npx skills add zaaack/prompts/zaaack-prompts-keyv-browser

keyv-browser

keyv-browser provides two specialized storage adapters that allow the standard Keyv API to work seamlessly within a web browser environment.


Available Adapters

AdapterStorage EngineBest For
KeyvLocalStoragewindow.localStorageSimple, synchronous, small strings (<5MB).
KeyvIndexedDBIndexedDBLarger datasets, binary data, and non-blocking I/O.

Usage Patterns

1. Standard Keyv Integration

You can swap the storage engine based on your persistence needs without changing your application logic.

import Keyv from 'keyv'
import { KeyvLocalStorage, KeyvIndexedDB } from 'keyv-browser'

// For simple settings
const settingsStore = new Keyv({
  store: new KeyvLocalStorage()
});

// For heavy data/caching
const cacheStore = new Keyv({
  store: new KeyvIndexedDB()
});

2. Declarative "Field" Usage

Use makeField to create direct, type-safe accessors for specific keys.

import { KeyvLocalStorage, makeField } from 'keyv-browser'

class AppStore extends KeyvLocalStorage {
  // makeField(store, key, defaultValue)
  theme = makeField(this, 'ui_theme', 'light')
  sessionCount = makeField(this, 'session_count', 0)
}

const store = new AppStore()

// Note: keyv-browser operations are asynchronous
await store.theme.set('dark')
const currentTheme = await store.theme.get() // 'dark'

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

nstate

No summary provided by upstream source.

Repository SourceNeeds Review
General

keyv-file

No summary provided by upstream source.

Repository SourceNeeds Review
General

create-skill

No summary provided by upstream source.

Repository SourceNeeds Review