Drivers

Capacitor Preferences

Store data via Capacitor Preferences API on mobile devices or local storage on the web.

Learn more about Capacitor Preferences API.

Usage

To use this driver, you need to install and sync @capacitor/preferences inside your capacitor project:

npm i @capacitor/preferences
npx cap sync

Usage:

import { createStorage } from "unstorage";
import capacitorPreferences from "unstorage/drivers/capacitor-preferences";

const storage = createStorage({
  driver: capacitorPreferences({
    base: "test",
  }),
});

Options:

  • base: Add ${base}: to all keys to avoid collision