From 4980736786880d0300393ca36df199a7b5528520 Mon Sep 17 00:00:00 2001 From: robobun Date: Mon, 8 Dec 2025 09:25:00 -0800 Subject: [PATCH] docs(server): fix `satisfies Serve` type in export default example (#25410) --- docs/runtime/http/server.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/runtime/http/server.mdx b/docs/runtime/http/server.mdx index 59083df7f2..432117e66f 100644 --- a/docs/runtime/http/server.mdx +++ b/docs/runtime/http/server.mdx @@ -193,15 +193,17 @@ This is the maximum amount of time a connection is allowed to be idle before the Thus far, the examples on this page have used the explicit `Bun.serve` API. Bun also supports an alternate syntax. ```ts server.ts -import { type Serve } from "bun"; +import type { Serve } from "bun"; export default { fetch(req) { return new Response("Bun!"); }, -} satisfies Serve; +} satisfies Serve.Options; ``` +The type parameter `` represents WebSocket data — if you add a `websocket` handler with custom data attached via `server.upgrade(req, { data: ... })`, replace `undefined` with your data type. + Instead of passing the server options into `Bun.serve`, `export default` it. This file can be executed as-is; when Bun sees a file with a `default` export containing a `fetch` handler, it passes it into `Bun.serve` under the hood. ---