diff options
author | 2023-09-07 10:09:09 -0700 | |
---|---|---|
committer | 2023-09-07 10:09:09 -0700 | |
commit | 5424ea3403df9cd4672290865f12b6f5b01cf2d0 (patch) | |
tree | 27e19a70fba49ffdd944c190163f5e8322d7a32f /docs/api/websockets.md | |
parent | 4b63ced72dc1b304e737d9ea055c8b6e75f46119 (diff) | |
download | bun-5424ea3403df9cd4672290865f12b6f5b01cf2d0.tar.gz bun-5424ea3403df9cd4672290865f12b6f5b01cf2d0.tar.zst bun-5424ea3403df9cd4672290865f12b6f5b01cf2d0.zip |
Doc updates for v1.0 (#4485)
* Remove v0.x messages
* Add windows section to Installatino
* update
* update
* Update
* Comment out windows
Diffstat (limited to 'docs/api/websockets.md')
-rw-r--r-- | docs/api/websockets.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/api/websockets.md b/docs/api/websockets.md index b8b7f7a8e..defc9e18c 100644 --- a/docs/api/websockets.md +++ b/docs/api/websockets.md @@ -12,6 +12,18 @@ Internally Bun's WebSocket implementation is built on [uWebSockets](https://github.com/uNetworking/uWebSockets). {% /callout %} +## Connect to a WebSocket server + +{% callout %} +**🚧** — The `WebSocket` client still does not pass the full [Autobahn test suite](https://github.com/crossbario/autobahn-testsuite) and should not be considered ready for production. +{% /callout %} + +Bun implements the `WebSocket` class. To create a WebSocket client that connects to a `ws://` or `wss://` server, create an instance of `WebSocket`, as you would in the browser. + +```ts +const socket = new WebSocket("ws://localhost:3000"); +``` + ## Start a WebSocket server Below is a simple WebSocket server built with `Bun.serve`, in which all incoming requests are [upgraded](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) to WebSocket connections in the `fetch` handler. The socket handlers are declared in the `websocket` parameter. |