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 adapter applies keepAliveOnUnmount. createInvoker does not read it.

The default rule for a retry:

  • SignalRDisabledError and SignalRDisconnectedError never retry.
  • If the hub is not connected, the call retries.
  • If the hub is connected, the call retries only for a SignalR TimeoutError, an AbortError, or an HttpError with status 0, 408, 429, or 5xx.

A HubException that the server throws never retries by default.

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.

Status values

StatusMeaning
"idle"No connection is wanted: before the start, enabled false, no baseUrl, a lazy hub without a consumer, or briefly during a rebuild.
"connecting"The first attempt runs, or the library waits for its next rebuild. The status stays "connecting" through all retries.
"connected"The connection is up.
"reconnecting"SignalR auto-reconnect runs. This needs reconnect other than false.
"disconnected"The hub is wanted but stopped for good: a 400, 401, 403, or 404 on negotiate, or a configuration error. The library does not retry.

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