When you need to offload CPU-intensive work or run parallel tasks in Bun without blocking your main thread, this covers both Web Workers and Node.js worker_threads APIs. You get practical patterns like worker pools, parallel mapping, and progress reporting, plus the crucial bits about transferable objects and SharedArrayBuffer for efficient data passing. The worker pool implementation is especially handy if you're processing batches of data. One thing to note: the examples lean heavily on TypeScript, which matches how most people actually use Bun, but you'll need to understand the difference between Web Workers (browser-style) and worker_threads (Node-style) to pick the right one for your use case.

skills.sh installs
333
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill bun-workers --agent claude-code

Installs into .claude/skills of the current project.

Files

Bun Workers

Bun supports Web Workers and Node.js worker_threads for parallel execution.

Web Workers

Basic Usage

// main.ts
const worker = new Worker(new URL("./worker.ts", import.meta.url));

worker.postMessage({ type: "start", data: [1, 2, 3, 4, 5] });

worker.onmessage = (event) => {
  console.log("Result:", event.data);
};

worker.onerror = (error) => {
  console.error("Worker error:", error.message);
};

// worker.ts
self.onmessage = (event) => {
  const { type, data } = event.data;

  if (type === "start") {
    const result = data.map((x) => x * 2);
    self.postMessage(result);
  }
};

Worker with URL

// Import from file path
const worker = new Worker(new URL("./worker.ts", import.meta.url));

// Or with blob URL
const code = `
  self.onmessage = (e) => {
    self.postMessage(e.data * 2);
  };
`;
const blob = new Blob([code], { type: "application/javascript" });
const worker = new Worker(URL.createObjectURL(blob));

Transferable Objects

// main.ts
const buffer = new ArrayBuffer(1024 * 1024); // 1MB
const view = new Uint8Array(buffer);
view.fill(42);

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Automation & Workflows
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1tech-leads-club avatarperf-lighthousetech-leads-club/agent-skillsRun Lighthouse audits locally via CLI or Node API, parse and interpret reports, and set performance budgets. Use when measuring site performance, understanding 332skills.sh installs
2davila7 avatarfigmadavila7/claude-code-templatesUse the Figma MCP server to fetch design context, screenshots, variables, and assets from Figma, and to translate Figma nodes into production code. Trigger when331skills.sh installs
3jdrhyne avatargoogle-adsjdrhyne/agent-skillsQuery, audit, and optimize Google Ads campaigns. Supports two modes: (1) API mode for bulk operations with the google-ads Python SDK, (2) attached-browser mode 331skills.sh installs
4glebis avatardeep-researchglebis/claude-skillsThis skill should be used when conducting comprehensive research on any topic using the OpenAI Deep Research API. It automates prompt enhancement through intera330skills.sh installs
5secondsky avatarbun-react-ssrsecondsky/claude-skillsUse when building server-rendered React with Bun, including streaming SSR, hydration, renderToString, or custom SSR without a framework.330skills.sh installs
6dirien avatarpulumi-typescriptdirien/claude-skillsScaffolds Pulumi TypeScript infrastructure-as-code projects, writes IaC code with proper resource configuration, manages Pulumi ESC environments for centralized329skills.sh installs