Teact
Guides

Storage

storagePlugin with file or memory drivers; useStorage and useGlobalStorage for persistent key-value state.

Plugin

import { storagePlugin } from "@teactjs/storage";

storagePlugin({
  driver: "file",
  path: ".teact/storage.json",
});

The file driver's path is a JSON file (not a directory). Drivers: "memory" (ephemeral), "file" (JSON on disk), or a custom StorageDriver.

useStorage

Reactive per-key state:

import { useStorage } from "@teactjs/storage";

const [favorites, setFavorites] = useStorage<string[]>("favorites", []);

useGlobalStorage

Low-level async API: get, set, delete, has, keys, clear.

See @teactjs/storage.

On this page