Getting started

Runtime support

Understand what is available in Node.js, Bun, Deno, workerd, and browsers.

Runtime support

Overview

FeatureNode.jsBunDenoworkerdBrowser
DetectionYesYesYesYesYes
Runtime versionYesYesYesNot guaranteedNot guaranteed
Environment variablesYesYesWith permissionNoNo
User argumentsYesYesYesNoNo
Current directoryYesYesWith permissionNoNo
FetchVersion-dependentYesYesYesYes
Timers and URLYesYesYesYesYes
Web StreamsVersion-dependentYesYesYesYes

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.