Skip to content

Commit 5facd7c

Browse files
docs: update doc about the transports option
1 parent 9e70312 commit 5facd7c

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

docs/client-options.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,48 @@ Default value: `true`
340340

341341
Whether to add the timestamp query param to each request (for cache busting).
342342

343+
### `transportOptions`
344+
345+
*Added in v2.0.0*
346+
347+
Default value: `{}`
348+
349+
Transport-specific options.
350+
351+
Example:
352+
353+
```js
354+
import { io } from "socket.io-client";
355+
356+
const socket = io({
357+
path: "/path-for-http-long-polling/",
358+
transportOptions: {
359+
websocket: {
360+
path: "/path-for-websocket/"
361+
}
362+
}
363+
});
364+
```
343365

344366
### `transports`
345367

346-
Default value: `["polling", "websocket"]`
368+
<details className="changelog">
369+
<summary>History</summary>
370+
371+
| Version | Changes |
372+
|---------|--------------------------|
373+
| v4.7.0 | `webtransport` is added. |
374+
| v1.0.0 | First implementation. |
375+
376+
</details>
377+
378+
Default value: `["polling", "websocket", "webtransport"]`
347379

348380
The low-level connection to the Socket.IO server can either be established with:
349381

350382
- HTTP long-polling: successive HTTP requests (`POST` for writing, `GET` for reading)
351-
- [WebSocket](https://en.wikipedia.org/wiki/WebSocket)
383+
- [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
384+
- [WebTransport](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API)
352385

353386
The following example disables the HTTP long-polling transport:
354387

docs/server-options.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,17 @@ Default value: `["polling", "websocket"]`
565565

566566
The low-level transports that are allowed on the server-side.
567567

568-
See also: client-side [`transports`](client-options.md#transports)
568+
Example with WebTransport enabled:
569+
570+
```js
571+
const io = new Server({
572+
transports: ["polling", "websocket", "webtransport"]
573+
});
574+
```
569575

576+
Please check the WebTransport example [here](/get-started/webtransport).
577+
578+
See also: client-side [`transports`](client-options.md#transports)
570579

571580
### `upgradeTimeout`
572581

0 commit comments

Comments
 (0)