
Bun Hot Reloading
Covers both watch mode and hot mode for Bun development. Watch mode restarts your process in about 20ms when files change, which is fine for most scripts and tests. Hot mode is the interesting one: it reloads modules in place during Bun.serve without restarting, so you can preserve state like counters or WebSocket connections across changes. The import.meta.hot API gives you lifecycle hooks for cleanup and custom reload logic. Includes patterns for stateful servers using globalThis and a custom file watcher implementation if you need more control. The comparison table and common errors section are genuinely useful for knowing which flag to reach for.
- skills.sh installs
- 328
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill bun-hot-reloading --agent claude-codeInstalls into .claude/skills of the current project.
Files
Bun Hot Reloading
Bun provides built-in hot reloading for faster development cycles.
Watch Mode vs Hot Mode
| Feature | --watch | --hot |
|---|---|---|
| Behavior | Restart process | Reload modules |
| State | Lost on reload | Preserved |
| Speed | ~20ms restart | Instant reload |
| Use case | Any file type | Bun.serve HTTP |
Watch Mode (--watch)
Restarts the entire process when files change.
# Basic watch mode
bun --watch run src/index.ts
# Watch specific script
bun --watch run dev
# Watch with test runner
bun --watch test
package.json Scripts
{
"scripts": {
"dev": "bun --watch run src/index.ts",
"dev:server": "bun --watch run src/server.ts",
"test:watch": "bun --watch test"
}
}
Watch Behavior
- Watches imported files automatically
- Triggers on any
.ts,.tsx,.js,.jsxchange - Also watches
.jsonimports - Restarts with fresh state
Hot Mode (--hot)
Reloads modules in-place without restarting the process.
bun --hot run src/server.ts
HTTP Server Hot Reload
// src/server.ts
let counter = 0; // State preserved across hot reloads
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Category
- Backend & APIs
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Bun Redis328
- Bun Ffi326
- Bun Jest Migration326
- Bun Websocket Server326
- Cloudflare Workers Runtime Apis326
- Swift Best Practices326
- Bun Nuxt323
- Bun Macros322
- Cloudflare Workers Frameworks321
- Supabase Postgres Best Practices319
- Cloudflare Workers Ci Cd318
- Cloudflare Workers Dev Experience317
- Cloudflare Workers Observability315
- Cloudflare Workers Migration310
- Cloudflare Workers Multi Lang310
- Verification Before Completion310
- Nuxt Studio308
- Neon Vercel Postgres294
- Chrome Devtools288
- Database Sharding277
- Sveltia Cms277
- Google Gemini File Search272
- Tailwind V4 Shadcn8.2K
- Aceternity Ui1.6K