Typorithm · easy

Watch & Hot Reload

bun-hot-reloadbunwatchhot-reloaddev-server
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Watch & Hot Reload

0%

Bun Runtime

bun --watch run restarts the whole process on every file change (fresh process, drops state and connections). bun --hot run reloads code in-place inside the running process, preserving state and open connections — perfect for long-running servers.

bun --watch run index.ts watches your files and, on any change, kills the process and starts a brand-new one — a full restart that gives you a clean slate every time.

bun --hot run server.ts instead patches the new code into the already-running process, so module state and open connections are preserved rather than torn down.

The rule of thumb: reach for --watch for scripts and CLIs where a clean restart is fine, and --hot for servers where dropping live connections on every save would be painful.

01

--watch restarts the process on every file change.

02

--hot reloads code in-place without restarting.

03

--hot preserves state and open connections; --watch does not.

bun --watch run index.ts   // restart process on file change
bun --hot run server.ts    // reload code in-place, keep state
// --watch  -> full restart (fresh process, drops connections)
// --hot    -> in-place reload (preserves open connections)

Read the implementation

Connect each part of the code to the concept before you type.

1. Watch mode

--watch restarts the whole process every time a watched file changes — a fresh start each time.

bun --watch run index.ts   // restart process on file change

2. Hot reload

--hot swaps the code in-place inside the running process, so state and open connections survive.

bun --hot run server.ts    // reload code in-place, keep state

3. Restart semantics

Because --watch spawns a fresh process, anything held in memory — like open sockets — is dropped.

// --watch  -> full restart (fresh process, drops connections)

4. In-place semantics

--hot is ideal for servers: it reloads the handler code without restarting, keeping connections alive.

// --hot    -> in-place reload (preserves open connections)

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Watch & Hot Reload: Lesson & Practice · Typorithm | ApplyDjinn