aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/api/websockets.md18
1 files changed, 5 insertions, 13 deletions
diff --git a/docs/api/websockets.md b/docs/api/websockets.md
index defc9e18c..e704419bb 100644
--- a/docs/api/websockets.md
+++ b/docs/api/websockets.md
@@ -12,18 +12,6 @@
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.
@@ -248,7 +236,11 @@ This gives you better control over backpressure in your server.
## Connect to a `Websocket` server
-To connect to an external socket server, either from a browser or from Bun, create an instance of `WebSocket` with the constructor.
+{% 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");