use-signalr
Reference

Configuration reference

Every option of the client config, the hub config, the calls, and the provider.

This page lists every option with its type and default. The concept pages explain how the options work together.

Client config

You pass these options to createSignalRClient. They are the global defaults for all hubs.

Prop

Type

BuilderContext is { hub: string; baseUrl: string }.

The options transport, skipNegotiation, and maxConnectRetries do not exist at the top level or per hub. transport and skipNegotiation belong in httpOptions. maxConnectRetries does not exist, because the library retries until the hub stops. createSignalRClient throws an error when it finds one of them.

Hub config

Each value in hubs can override the global options for one hub. The global value is the fallback.

Prop

Type

Each hub value also holds events and methods. Declare each event with event<[...args]>(), and each method with method<[...args], Return>().

skipNegotiation: true in httpOptions needs transport set to HttpTransportType.WebSockets. Any other value throws an error when you create the client: Hub "<hub>": skipNegotiation needs httpOptions.transport = HttpTransportType.WebSockets.

A binary protocol object with transport set to HttpTransportType.ServerSentEvents throws an error when you create the client.

Invoke options

You pass these options to the invoke helper of a method.

Prop

Type

The Calls page explains the default retry rule.

Teardown options

Prop

Type

The teardown sender resolves false when the hub did not connect within the timeout, the session is disabled, the hub failed, or send rejected. The send helper resolves false when the hub is not connected, or when send() rejects.

Provider values

The values that you pass to createSession are in Provider.

Without onError, the library drops errors silently. In Lit, onStatusChange and onError are fixed when you create the session. session.update() changes baseUrl, enabled, connectionKey, and accessTokenFactory. It rebuilds only when baseUrl, enabled, or connectionKey change.

Status values

A hub has one of five statuses: "idle", "connecting", "connected", "reconnecting", and "disconnected". Connection status explains each value and the transitions.

Retry timing

LayerDelaysLimit
SignalR auto-reconnectThe reconnect delays. The default is 0, 2, 10, and 30 seconds.The end of the delay list.
Library rebuildmin(2500 × attempt, 30000) msNone while the hub is wanted. It stops on a non-retriable error.

The connect errors 400, 401, 403, and 404 are non-retriable. Every other status code and error retries, for example 0, 408, 429, and 5xx.

On this page