oruntime

Write code around the capabilities it needs, not around the runtime that executes it.

oruntime detects the current JavaScript environment and provides a typed, consistent API for inspecting its capabilities, reading environment variables, accessing arguments, finding the current working directory, and using portable primitives for Fetch, timers, and URLs.

Framework-agnostic and built on Web standards, the library lets you share the same code across Node.js, Bun, Deno, Cloudflare Workers, and browsers without hiding the important differences between those environments.

Get started
Install oruntime, detect your runtime, and use your first adapter.
Detection and capabilities
Learn how runtimes are identified and what each environment supports.
Runtime adapter
Use a stable interface for runtime-specific information and operations.

Runtime features

Detection
Identify Node.js, Bun, Deno, workerd, and browsers.
Capabilities
Check which APIs are available before using them.
Environment
Read one variable or the complete environment.
Fetch
Make requests and validate responses consistently.
Timers
Wait or enforce a deadline with AbortSignal.
URL
Create, resolve, and enrich URLs with portable functions.

What the library supports

  • ordered runtime detection and runtime versions when available;
  • a typed description of the capabilities that are actually present;
  • a common interface for environment variables, arguments, and the current directory;
  • Fetch utilities with response validation and JSON or text readers;
  • abortable timers and explicit timeouts;
  • URL creation, resolution, and modification;
  • common errors with stable codes and preserved causes;
  • extension points for injecting globals in tests.
oruntime does not reimplement file systems, paths, HTTP or WebSocket servers, cryptography, or encoding. Those responsibilities remain with native APIs and specialized libraries. See the project scope to understand these decisions.