---
title: "openvibe-sdk/realtime · OpenVibe.Services"
canonical: "https://openvibe.services/docs/sdk/realtime"
updated: null
---

# openvibe-sdk/realtime · OpenVibe.Services

HTML: [openvibe-sdk/realtime · OpenVibe.Services](https://openvibe.services/docs/sdk/realtime)

# `openvibe-sdk/realtime`

Generated at 2026-12-01 05:42:00 UTC from [`openvibe-contracts v0.454.0`](https://github.com/OpenVibers/OpenVibe.Contracts/tree/v0.454.0) and [`openvibe-sdk v0.193.0`](https://github.com/OpenVibers/OpenVibe.SDK/tree/v0.193.0).

From `types/realtime.d.ts` (both). Declarations are shown verbatim.

## interface RealtimeGap

~~~~
export interface RealtimeGap { reason: 'retention' | 'replay_limit' | 'cursor_ahead' | string; from_seq: number; to_seq: number; latest_seq?: number; }
~~~~

## interface RealtimeMeta

\`cursor\` is the position to save (dedupe is by event\_id, inside the client).

~~~~
export interface RealtimeMeta { cursor: string | null; }
~~~~

## interface SubscribeOptions

~~~~
export interface SubscribeOptions {
    client?: OpenVibeClient;
    /** Events origin or the full …/realtime/stream URL; default from the client's registry, else https://openvibe.events */
    url?: string;
    baseUrl?: string;
    /** Resume after this opaque cursor (the `cursor` a callback was given, saved before a reload). */
    lastEventId?: string | null;
    onGap?: (gap: RealtimeGap) => void;
    onOpen?: () => void;
    onError?: (err: Error) => void;
    /** A Bearer token forces the fetch transport (EventSource cannot send headers). */
    token?: string;
    getToken?: (ctx: TokenContext) => Promise<string | null | undefined> | string | null | undefined;
    withCredentials?: boolean;
    transport?: 'auto' | 'eventsource' | 'fetch';
    reconnectDelayMs?: number;
    maxReconnectDelayMs?: number;
    fetch?: FetchLike;
    EventSource?: any;
}
~~~~

## interface RealtimeSubscription

~~~~
export interface RealtimeSubscription {
    close(): void;
    /** The last SSE id as Events sent it: an opaque cursor (ADR-042), or a seq from an older Events. Save it to resume. */
    readonly lastEventId: string | null;
    readonly transport: 'eventsource' | 'fetch';
    readonly connected: boolean;
    readonly closed: boolean;
    readonly done: Promise<void>;
}
~~~~

## function subscribe

~~~~
export declare function subscribe(topics: string | string[], onEvent: (event: EventEnvelope, meta: RealtimeMeta) => void, opts?: SubscribeOptions): RealtimeSubscription;
~~~~

## function createRealtimeClient

~~~~
export declare function createRealtimeClient(client: OpenVibeClient, defaults?: Omit<SubscribeOptions, 'client'>): { subscribe(topics: string | string[], onEvent: (event: EventEnvelope, meta: RealtimeMeta) => void, opts?: SubscribeOptions): RealtimeSubscription };
~~~~

## interface SSEMessage

~~~~
export interface SSEMessage { event: string; data: string; id: string | undefined; }
~~~~

## function parseSSE

WHATWG event-stream parser over a fetch body (or any async iterable of chunks).

~~~~
export declare function parseSSE(body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array | string>, opts?: { onRetry?: (ms: number) => void }): AsyncGenerator<SSEMessage, void, unknown>;
~~~~

## const DEFAULT\_ORIGIN

~~~~
export declare const DEFAULT_ORIGIN: string;
~~~~
