SponsorkitStorage

Where the SDK keeps its per-target-set document.

On this page

Where the SDK keeps its per-target-set document. Implementations store an opaque JSON string per targetsHash.

Built in: localStorageAdapter() (browsers), memoryStorage(), and fileStorage(dir) from @sponsorkit/sdk/node.

import type { SponsorkitStorage } from "@sponsorkit/sdk";

interface SponsorkitStorage { … }

Interface, exported from @sponsorkit/sdk, @sponsorkit/sdk/node.

Methods#

read()#

read(targetsHash: string): string | null | Promise<string | null>

The stored JSON for targetsHash, or null.

Parameters

ParameterTypeDefaultDescription
targetsHashstringrequired

Returns string | null | Promise<string | null>

write()#

write(targetsHash: string, json: string): void | Promise<void>

Replaces the stored JSON for targetsHash. Should be atomic.

Parameters

ParameterTypeDefaultDescription
targetsHashstringrequired
jsonstringrequired

Returns void | Promise<void>