# Offline queue

Signed entries and exact-event replay.

[Read the offline writes guide](/docs/offline-writes/). Signatures below come from the published SDK declarations. Access SDK services through `db`; use their constructors only when integrating at a lower level.

## OfflineOptions


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

## QueuedWriteReceipt


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

## NostrbaseOffline


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

### Properties


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

### constructor


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

### attachAutoReplay


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

### startAutoReplay


```ts
startAutoReplay(options?: AutoReplayOptions): void;
```

### stopAutoReplay


```ts
stopAutoReplay(): void;
```

### notifyReplayWork


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

### hasPending


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

### ready


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

### enqueueSigned


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

### list


```ts
list(): Promise<QueuedEvent[]>;
```

### remove


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

### flush


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

### close


```ts
close(): Promise<void>;
```


## Supporting declarations

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

### OfflineHost


```ts
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>;
}
```
