[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [WebSocket](https://evolu.dev/docs/api-reference/common/WebSocket) › WebSocketOptions

Defined in: [packages/common/src/WebSocket.ts:103](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L103)

Options for creating [WebSocket](https://evolu.dev/docs/api-reference/common/WebSocket/interfaces/WebSocket).

## Properties

<a id="binarytype"></a>

### binaryType?

```ts
readonly optional binaryType?: "blob" | "arraybuffer";
```

Defined in: [packages/common/src/WebSocket.ts:108](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L108)

Sets the binary type for the data being received.

---

<a id="onclose"></a>

### onClose?

```ts
readonly optional onClose?: (event: CloseEvent) => void;
```

Defined in: [packages/common/src/WebSocket.ts:117](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L117)

Callback when the connection is closed.

### onError?

```ts
readonly optional onError?: (error: WebSocketError) => void;
```

Defined in: [packages/common/src/WebSocket.ts:114](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L114)

Callback when an error occurs.

### onMessage?

```ts
readonly optional onMessage?: (data:
  | string
  | Blob
  | ArrayBuffer) => void;
```

Defined in: [packages/common/src/WebSocket.ts:127](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L127)

Callback when message data is received.

### onOpen?

```ts
readonly optional onOpen?: () => void;
```

Defined in: [packages/common/src/WebSocket.ts:111](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L111)

Callback when the connection is established.

### protocols?

```ts
readonly optional protocols?: string | readonly string[];
```

Defined in: [packages/common/src/WebSocket.ts:105](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L105)

Protocol(s) to use with the WebSocket connection.

---

<a id="schedule"></a>

### schedule?

```ts
readonly optional schedule?: Schedule<number & Brand<"Int"> & Brand<"NonNegative"> & Brand<"LessThan281474976710655"> & Brand<"Millis">, WebSocketRetryError>;
```

Defined in: [packages/common/src/WebSocket.ts:137](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L137)

Retry schedule for reconnection. Defaults to:

```ts
// A jittered, capped, unlimited exponential backoff.
jitter(1)(maxDelay("30s")(exponential("100ms")));
```

---

<a id="shouldretryonclose"></a>

### shouldRetryOnClose?

```ts
readonly optional shouldRetryOnClose?: (event: CloseEvent) => boolean;
```

Defined in: [packages/common/src/WebSocket.ts:124](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L124)

Determines whether a closed connection should trigger a retry.

Return false to stop retrying, for example on auth errors or maintenance.

### WebSocketConstructor?

```ts
readonly optional WebSocketConstructor?: {
(url: string | URL, protocols?: string | string[]): WebSocket;
  CLOSED: 3;
  CLOSING: 2;
  CONNECTING: 0;
  OPEN: 1;
  prototype: WebSocket;
};
```

Defined in: [packages/common/src/WebSocket.ts:146](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/WebSocket.ts#L146)

For custom WebSocket implementations.

This supports blob:

https://github.com/callstackincubator/react-native-fast-io