secondsky avatar

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-code

Installs 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
BehaviorRestart processReload modules
StateLost on reloadPreserved
Speed~20ms restartInstant reload
Use caseAny file typeBun.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, .jsx change
  • Also watches .json imports
  • 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
1secondsky avatarcloudflare-workers-runtime-apissecondsky/claude-skillsCloudflare Workers Runtime APIs including Fetch, Streams, Crypto, Cache, WebSockets, and Encoding. Use for HTTP requests, streaming, encryption, caching, real-t326skills.sh installs
2secondsky avatarswift-best-practicessecondsky/claude-skills| This skill should be used when writing or reviewing Swift code for iOS or macOS projects. Apply modern Swift 6+ best practices, concurrency patterns, API desi326skills.sh installs
3vinayakkulkarni avatarnuxt-best-practicesvinayakkulkarni/vue-nuxt-best-practicesNuxt 4 performance optimization and architecture guidelines (current through Nuxt 4.5) for building fast, maintainable full-stack applications. This skill shoul325skills.sh installs
4checkly avatarchecklycheckly/checkly-cliSet up, create, test and manage monitoring checks using the Checkly CLI. Use when working with API Checks, Browser Checks, URL Monitors, ICMP Monitors, Playwrig321skills.sh installs
5fanzhidongyzby avatarserper-scholarfanzhidongyzby/openclaw-serper使用 Google Scholar API 进行学术搜索,查找论文、研究报告、学术文献,获取引用信息、作者、发表刊物等详细信息。321skills.sh installs
6secondsky avatarcloudflare-workers-frameworkssecondsky/claude-skillsFramework integration for Cloudflare Workers. Use when building with Hono, Remix, Next.js, Astro, SvelteKit, Qwik, or Nuxt on Workers. Covers routing, SSR, stat321skills.sh installs