Runtime support
Runtime support
Overview
| Feature | Node.js | Bun | Deno | workerd | Browser |
|---|---|---|---|---|---|
| Detection | Yes | Yes | Yes | Yes | Yes |
| Runtime version | Yes | Yes | Yes | Not guaranteed | Not guaranteed |
| Environment variables | Yes | Yes | With permission | No | No |
| User arguments | Yes | Yes | Yes | No | No |
| Current directory | Yes | Yes | With permission | No | No |
| Fetch | Version-dependent | Yes | Yes | Yes | Yes |
| Timers and URL | Yes | Yes | Yes | Yes | Yes |
| Web Streams | Version-dependent | Yes | Yes | Yes | Yes |
The table describes the general model. Web-standard globals are checked at runtime because availability also depends on the runtime version and execution context.
Node.js
Node.js is detected through process.versions.node, which also provides its version. Environment variables, arguments, and the current directory use process.
Bun
Bun is checked before Node.js because it also exposes Node-compatible APIs. Its version comes from Bun.version, its environment from Bun.env, and its arguments and current directory from process.
Deno
Deno is detected through the Deno global and Deno.version.deno. Environment and current-directory access may require permissions. See the Deno permissions guide.
Cloudflare Workers and workerd
workerd is identified from the platform user agent. Processes, CLI arguments, and current directories do not exist in this model:
runtime.getEnv('KEY') // undefined
runtime.getEnv() // {}
runtime.cwd() // undefined
runtime.argv() // []
Browser
A browser is identified when window and document exist. A Web Worker without a window may be returned as unknown.
Unknown environments
By default, an unrecognized environment produces unknown and a neutral adapter. Use strict mode when continuing would be unsafe:
const runtime = createRuntimeAdapter({ throwOnUnknown: true })
Version policy
The library targets modern runtimes that provide the required Web standards. Capabilities are checked at runtime rather than inferred solely from a version number.