Skip to content

Hot Reload

Nadhi-(Kushi) edited this page Apr 1, 2026 · 2 revisions

Hot Reload

The current dev reload story is built around three entry points:

  • app.reload(...)
  • http-native dev <entry>
  • createDevServer(...)

For older code, listen().hot() and @http-native/core/hot still exist as compatibility paths.

CLI

http-native dev ./server.ts --port 3000

Options:

  • --host
  • --port
  • --watch path (repeatable)
  • --debounce ms
  • --no-clear

App-Level Reload Config

import { createApp } from "@http-native/core";

const app = createApp().reload({
  files: ["src", "routes", "rsrc/src"],
  debounceMs: 80,
  clear: true,
});

app.get("/", (req, res) => {
  res.json({ ok: true });
});

await app.listen().port(3000).hot();

app.reload() stores the watch and reload settings on the app. .listen().hot() turns on the runtime reload path for self-starting apps.

Programmatic Dev Server

import { createDevServer } from "@http-native/core/dev";

const dev = await createDevServer({
  entry: "./server.ts",
  port: 3000,
  watch: ["src", "routes"],
  debounceMs: 80,
  clear: true,
});

console.log(dev.url);
console.log(dev.status());

DevServerHandle exposes:

  • host
  • port
  • url
  • status()
  • reload(reason?)
  • close()

Compatibility Wrapper

import { hot } from "@http-native/core/hot";

await hot("./server.ts", {
  port: 3000,
});

Runtime Notes

  • Reload keeps the active JS runtime. Bun stays on Bun. Node stays on Node.
  • app.reload() accepts watch or files.
  • No hardcoded extension allowlist is required from the public API. You decide the watch roots.
  • close() is intended to stop the watcher and close the dev server immediately.

Clone this wiki locally