Skip to main content
Very Popular
Go to Latest
interface StorageAdapter
import { type StorageAdapter } from "";

A storage adapter is an abstraction that provides read, write, and delete access to a storage solution of any kind. Storage adapters are used to keep session middleware independent of your database provider, and they allow you to pass your own storage solution.


read: (key: string) => MaybePromise<T | undefined>

Reads a value for the given key from the storage. May return the value or undefined, or a promise of either.

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

Writes a value for the given key to the storage.

delete: (key: string) => MaybePromise<void>

Deletes a value for the given key from the storage.

has: (key: string) => MaybePromise<boolean>

Checks whether a key exists in the storage.

readAllKeys: () => Iterable<string> | AsyncIterable<string>

Lists all keys.

readAllValues: () => Iterable<T> | AsyncIterable<T>

Lists all values.

readAllEntries: () => Iterable<[string, T]> | AsyncIterable<[string, T]>

Lists all keys with their values.