# workerd — Cloudflare Workers JavaScript Runtime > workerd is the open-source JavaScript and WebAssembly runtime that powers Cloudflare Workers. It can be self-hosted to run Workers-compatible code locally or on your own infrastructure with the same V8 isolate-based execution model. ## Install Save in your project root: # workerd — Cloudflare Workers JavaScript Runtime ## Quick Use ```bash # Build from source (requires Bazel and clang) git clone https://github.com/cloudflare/workerd.git cd workerd bazel build //src/workerd/server:workerd # Or use via wrangler for local dev npx wrangler dev --experimental-local ``` ## Introduction workerd is the open-source runtime behind Cloudflare Workers, released by Cloudflare in 2022. It uses V8 isolates to run JavaScript and WebAssembly workloads with sub-millisecond cold starts and strong per-request isolation. Unlike Node.js, it implements Web Platform APIs (fetch, Request, Response, crypto) rather than Node-specific APIs. ## What workerd Does - Executes JavaScript and TypeScript using V8 isolates with Web Platform APIs - Runs WebAssembly modules alongside JavaScript workers - Provides per-request isolation without the overhead of separate processes or containers - Implements the Service Workers API and Cloudflare-specific bindings (KV, R2, D1) - Serves as the local runtime behind wrangler dev for Workers development ## Architecture Overview workerd is written in C++ using the Cap'n Proto framework for its configuration and RPC layer. Each incoming request runs in its own V8 isolate, providing memory isolation without process-level overhead. The runtime implements a subset of Web Platform APIs (Fetch, Streams, Web Crypto, URL, TextEncoder) and adds Cloudflare-specific bindings. Configuration is defined in a Cap'n Proto schema file that specifies services, routes, and bindings. ## Self-Hosting & Configuration - Build from source using Bazel with a C++20 compiler (clang 15+) - Configuration uses Cap'n Proto schema files to define workers and routing - Bind workers to specific ports and URL patterns via the config - Environment variables and secrets are injected through the binding configuration - Can run standalone or be embedded as a library in other C++ applications ## Key Features - Sub-millisecond cold starts using V8 isolate reuse - Per-request memory isolation without container overhead - Web Platform API compatibility (not Node.js APIs) - WebAssembly support for running compiled code alongside JS - Same runtime used in production by Cloudflare Workers globally ## Comparison with Similar Tools - **Node.js** — general-purpose JS runtime with OS-level APIs; workerd focuses on Web Platform APIs with isolate-level isolation - **Deno** — secure JS/TS runtime; workerd is more specialized for edge/serverless workloads - **Bun** — performance-focused JS runtime; workerd prioritizes isolation and cold start speed over raw throughput - **WinterJS** — Wasmer-based JS runtime; workerd uses V8 and has battle-tested production parity with Cloudflare - **Fastly Compute** — proprietary edge runtime; workerd is open source and self-hostable ## FAQ **Q: Can I run workerd locally for development?** A: Yes. The wrangler CLI uses workerd under the hood for local development via wrangler dev. **Q: Does workerd support Node.js APIs?** A: Partially. A Node.js compatibility layer is available for common modules like Buffer and crypto, but workerd primarily targets Web Platform APIs. **Q: Is workerd suitable for self-hosted production use?** A: workerd is designed for Cloudflare infrastructure. Self-hosting is possible but requires building from source and managing the configuration yourself. Community tooling around self-hosting is limited. **Q: What is the difference between workerd and miniflare?** A: miniflare was a Node.js-based Workers simulator. It has been replaced by workerd as the local runtime, providing true parity with the production environment. ## Sources - https://github.com/cloudflare/workerd - https://blog.cloudflare.com/workerd-open-source-workers-runtime/ --- Source: https://tokrepo.com/en/workflows/asset-d7bc2488 Author: AI Open Source