SSE Hooks

useIndexedDB

Custom hook that provides an interface to the [IndexedDB API](https://developer.

Installation

npx sse-tool add use-indexed-db

Usage

import { useIndexedDB } from "./{hooks file}";

interface UserProfile {
  name: string;
  age: number;
}

const { setItem, getItem, data } = useIndexedDB<UserProfile>(
  "myAppDB",
  "profiles",
);

const saveProfile = async () => {
  await setItem("user_1", { name: "Alice", age: 30 });
};

API

Parameters

NameTypeDescription
databaseNamestringThe name of the IndexedDB database.
storeNamestringThe name of the object store within the database.
optionsUseIndexedDBOptionsConfiguration options for the database connection (optional).

Return Value

Returns UseIndexedDBReturn.

An object containing the current data state, error state, loading state, and methods to interact with the database.

Changelog

No recent changes.
Built with Love • © 2026