Back to Apollo Client

WebSocketLink

docs/source/api/link/apollo-link-ws.mdx

3.14.11.2 KB
Original Source
<Caution>

We no longer recommend using WebSocketLink or the subscriptions-transport-ws library, because the library is not actively maintained. To execute subscriptions, We instead recommend using the newer graphql-ws library with the accompanying GraphQLWsLink.

Whichever library you use, make sure you use the same library in your server and any clients you support. For more information, see Choosing a subscription library.

</Caution>

<DocBlock canonicalReference="@apollo/client/link/ws!WebSocketLink:class" customOrder={["summary", "remarks", "example"]} />

Constructor signature

ts
constructor(
  paramsOrClient: WebSocketLink.Configuration | SubscriptionClient
): WebSocketLink

Installation

WebSocketLink requires the subscriptions-transport-ws library. Install it in your project:

shell
npm install subscriptions-transport-ws

Types

<InterfaceDetails canonicalReference="@apollo/client/link/ws!WebSocketLink.Configuration:interface" headingLevel={3} displayName="WebSocketLink.Configuration" />