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 changeTyporithm · easy
Step 1 of 8 · intro card
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.
--watch restarts the process on every file change.
--hot reloads code in-place without restarting.
--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)Connect each part of the code to the concept before you type.
--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--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 stateBecause --watch spawns a fresh process, anything held in memory — like open sockets — is dropped.
// --watch -> full restart (fresh process, drops connections)--hot is ideal for servers: it reloads the handler code without restarting, keeping connections alive.
// --hot -> in-place reload (preserves open connections)Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.