nostrbasedocs
Start building
API reference
.md

Read the offline writes guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.

OfflineOptions

interface OfflineOptions {
  adapter?: PersistenceAdapter;
  maxEntries?: number;
  autoReplay?: boolean | AutoReplayOptions;
}

QueuedWriteReceipt

interface QueuedWriteReceipt extends WriteReceipt {
  queued: true;
  persisted: true;
}

NostrbaseOffline

/** Explicit queue of already signed events. Replay never asks a signer to create new events. */
declare class NostrbaseOffline {}

Properties

readonly adapter: PersistenceAdapter;
get autoReplayStatus(): AutoReplayStatus;

constructor

constructor(host: OfflineHost, options?: OfflineOptions, shared?: PersistenceAdapter);

attachAutoReplay

/** Installed by the client after all queue hosts exist. */
attachAutoReplay(host: AutoReplayHost, options?: boolean | AutoReplayOptions): void;

startAutoReplay

startAutoReplay(options?: AutoReplayOptions): void;

stopAutoReplay

stopAutoReplay(): void;

notifyReplayWork

/** Wake only after a durable queue/publication obligation is committed. */
notifyReplayWork(): void;

hasPending

hasPending(pubkey: string): Promise<boolean>;

ready

/** Restore optimistic signed writes from the durable queue after cache hydration. */
ready(): Promise<void>;

enqueueSigned

enqueueSigned(event: NostrEvent): Promise<Result<QueuedWriteReceipt>>;

list

list(): Promise<QueuedEvent[]>;

remove

/** Cancel future delivery only. The optimistic cached event remains; no rollback or deletion is sent. */
remove(eventId: string): Promise<boolean>;

flush

flush(options?: { signal?: AbortSignal }): Promise<Result<WriteReceipt[]>>;

close

close(): Promise<void>;

Supporting declarations

These types appear in public signatures but are not package exports.

OfflineHost

interface OfflineHost {
  namespace: string;
  minWriteAcks: number;
  auth: {
    readonly revision?: number;
    readonly revisionSignal?: AbortSignal;
    getSession(): Promise<Result<Session>>;
  };
  ready(): Promise<void>;
  assertOpen(): void;
  signal(signal?: AbortSignal): AbortSignal;
  ingest(event: NostrEvent): boolean;
  publish(event: NostrEvent, signal?: AbortSignal): Promise<WriteReceipt>;
}

Search guides, API methods, and protocols.