From 177e02b304d331b5a3142d5e52d22fb368c4f33e Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Mon, 28 Aug 2023 12:55:22 -0700 Subject: docs: hot reloading with Bun.serve --- docs/api/http.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs/api') diff --git a/docs/api/http.md b/docs/api/http.md index 1029972a6..ec32274d7 100644 --- a/docs/api/http.md +++ b/docs/api/http.md @@ -189,7 +189,7 @@ Bun.serve({ }); ``` -## Hot reloading +## Object syntax Thus far, the examples on this page have used the explicit `Bun.serve` API. Bun also supports an alternate syntax. @@ -203,15 +203,15 @@ export default { } satisfies Serve; ``` -Instead of passing the server options into `Bun.serve`, export it. This file can be executed as-is; when Bun runs a file with a `default` export containing a `fetch` handler, it passes it into `Bun.serve` under the hood. +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. -This syntax has one major advantage: it is hot-reloadable out of the box. When any source file is changed, Bun will reload the server with the updated code _without restarting the process_. This makes hot reloads nearly instantaneous. Use the `--hot` flag when starting the server to enable hot reloading. + -```bash + -It's possible to configure hot reloading while using the explicit `Bun.serve` API; for details refer to [Runtime > Hot reloading](/docs/runtime/hot). + ## Streaming files -- cgit v1.2.3