Getting started

Introduction

Learn what oruntime does, which runtimes it targets, and the principles behind its API.

Introduction

oruntime is an ESM TypeScript library that provides compatibility primitives across JavaScript environments. It answers three questions:

  1. Which runtime is executing my code?
  2. Which capabilities are actually available?
  3. How can common features be used with consistent behavior?

Supported runtimes

RuntimeDescription
nodeNode.js
bunBun
denoDeno
workerdCloudflare Workers and workerd environments
browserA browser window with window and document
unknownAn unrecognized environment

What oruntime provides

Detection

Identify the runtime without accessing privileged APIs.

Adapter

Read the version, environment, arguments, and current directory.

Capabilities

Check whether APIs are available before calling them.

Portable utilities

Use Fetch, timeouts, cancellation, and URLs through a consistent API.

Philosophy

oruntime favors Web standards and APIs that already work across runtimes. It does not wrap an existing shared standard or replace specialized solutions.

Capability detection confirms that an API exists. It does not guarantee that permissions, platform policies, or configuration will allow a particular operation.

Minimal example

import { createRuntimeAdapter, fetchJSON } from 'oruntime'

const runtime = createRuntimeAdapter()
console.log(`Runtime: ${runtime.name} ${runtime.version ?? ''}`)

if (runtime.capabilities.fetch) {
  const status = await fetchJSON<{ ok: boolean }>('https://example.com/status')
  console.log(status.ok)
}

Next steps

  1. Install the package.
  2. Follow the quick start.
  3. Review runtime support.