use-signalr

Core

The framework-free package that owns all connection behavior. Read it if you build an adapter for another framework.

@dammers/use-signalr-core holds all connection behavior of use-signalr. It has no framework dependency. Its only peer dependency is @microsoft/signalr.

Who needs core

Adapter authors need core. An adapter connects the session of core to the reactivity and the lifecycle of one framework.

If you build an app, you do not need core. Install the adapter for your framework. The adapter installs core for you, and its API uses the vocabulary of your framework.

What core does

Core owns these parts:

  • Sessions that create and share one connection for each hub.
  • Lazy hubs, reference counts, and grace periods before a lazy hub disconnects.
  • Auto-reconnect, and a rebuild with backoff when a connection cannot recover.
  • Per-hub connection status.
  • The event registry, which keeps handlers across reconnects and rebuilds.
  • The invoke, send, and teardown call helpers.
  • Typed config resolution for global and per-hub options.
  • Cleanup and disposal.

An adapter owns only the framework side: reactive status, context propagation, lifecycle binding, and the public API names. Build an adapter describes this split and the contract in detail.

Official adapters

Each adapter is a thin layer over core. The adapters never import from each other.

Install

Install core together with @microsoft/signalr:

npm install @dammers/use-signalr-core @microsoft/signalr

The package is an ES module and ships its own types. The API reference lists every export of @dammers/use-signalr-core.

Where to go next

On this page