Skip to content

ConnectRelayOptions

Defined in: relay-sdks/ts/src/connect-session.ts:67

Connection options shared by connectRelaySubscriber and connectRelayPublisher: endpoint, token, lifetime signal, connection deadline, and transport injection. Each role’s options extend this with what only that role uses: ConnectRelaySubscriberOptions and ConnectRelayPublisherOptions.

connectTimeoutMs?: number;

Defined in: relay-sdks/ts/src/connect-session.ts:87

Deadline for token resolution, transport connection, and protocol SETUP. Default 10 seconds, maximum 2147483647.


createTransport?: RelayTransportFactory;

Defined in: relay-sdks/ts/src/connect-session.ts:93

Create the transport. Defaults to the browser’s WebTransport; a runtime without it, or whose WebTransport cannot negotiate protocols, fails with TRANSPORT_UNAVAILABLE unless this is supplied.


getToken?: () =>
| string
| RelayCredential
| Promise<
| string
| RelayCredential
| undefined>
| undefined;

Defined in: relay-sdks/ts/src/connect-session.ts:83

Resolve a connection token. Relay carries it in the endpoint’s jwt query parameter. An explicit jwt in the URL wins, and the provider is not called in that case. An empty jwt in the URL is a RangeError, raised before the provider or the transport is used. Return a RelayCredential to say when the token expires; for a bare token the connection reads the JWT’s exp claim, without verifying it. The provider runs once per connection: a live session keeps the token it connected with until the relay ends it at that expiry.

| string | RelayCredential | Promise< | string | RelayCredential | undefined> | undefined


signal?: AbortSignal;

Defined in: relay-sdks/ts/src/connect-session.ts:85

Aborting closes the connection, including after the connect call has resolved.


url?: string;

Defined in: relay-sdks/ts/src/connect-session.ts:74

Relay’s HTTPS WebTransport endpoint, including any endpoint path. Left out, the connection dials DEFAULT_ENDPOINT rooted at the token’s root claim, read without verifying the token: the URL roomEndpoint builds from that root. getToken is then required, and a token that names no usable root is a TypeError or RangeError before the transport is used. Pass url for another relay, region or room.