Skip to Content
V8-wasm
API Reference

API Reference

TypeDoc-generated reference for @browser-ports/v8-wasm, V8 C++ mirror bindings, GuestRealm membrane, and compatibility subpaths

@browser-ports/v8-wasm exposes V8's C++ public API directly to TypeScript over V8-wasm, alongside high-level realm isolation primitives (GuestRealm, Membrane), Chrome DevTools Protocol (InspectorBridge), and four drop-in compatibility subpaths.

The generated TypeScript binding surface covers 230 V8 C++ classes, 93 enums, 1,033 bound methods, and 1,142 Wasm exports (76.2% of the upstream V8 public header surface), documented directly from upstream V8 C++ headers via TypeDoc.

Package Entry Points

Import PathReferenceExportsPurpose
@browser-ports/v8-wasmCore Runtime & Realms19 classes, 33 functions, 9 interfaces, v8 namespaceInitialization, platforms, isolates, RAII scopes, GuestRealm, Membrane, InspectorBridge
@browser-ports/v8-wasm (V8 Mirror)Primitives & Values · Objects & Buffers · Scripts & Wasm · Isolates & Platform · Templates · Inspector & Profiler · Enums230 classes, 93 enums, 1,033 methodsFull generated V8 C++ public API mirror
@browser-ports/v8-wasm/shadowrealm-polyfillShadowRealm3 exportsTC39 ShadowRealm backed by a real V8-wasm Isolate and Context
@browser-ports/v8-wasm/sesSES / Hardened JS5 exportsCompartment, harden, and lockdown with disjoint V8 realms
@browser-ports/v8-wasm/jscJavaScriptCore C-API41 exportsDrop-in JSC C-API (JSGlobalContext*, JSEvaluateScript, JSValue*, JSObject*)
@browser-ports/v8-wasm/realm-sandboxRealm Sandbox4 exportsPage-level guest <script> and eval sandbox

V8 C++ Mirror Reference Groups

SectionClasses / EnumsBound MethodsUpstream V8 Headers
V8 Primitives, Values & Exceptions38 classes246v8-data.h, v8-value.h, v8-primitive.h, v8-primitive-object.h, v8-date.h, v8-regexp.h, v8-external.h, v8-exception.h, v8-message.h
V8 Objects, Containers & Buffers38 classes238v8-object.h, v8-function.h, v8-container.h, v8-promise.h, v8-proxy.h, v8-json.h, v8-array-buffer.h, v8-typed-array.h, v8-value-serializer.h
V8 Scripts, Modules & Wasm30 classes82v8-script.h, v8-wasm.h, v8-extension.h, v8-source-location.h
V8 Isolates, Contexts & Platform44 classes191v8-initialization.h, v8-isolate.h, v8-context.h, v8-microtask-queue.h, v8-platform.h, v8-snapshot.h
V8 Templates & Callbacks13 classes34v8-template.h, v8-callbacks.h
V8 Inspector, Profiler & Metrics71 classes242v8-inspector.h, v8-debug.h, v8-profiler.h, v8-metrics.h, v8-statistics.h
V8 Enumerations93 enums—All public V8 and v8_inspector enums

Initialization & Lifecycle Quickstart

Call initV8 once with the modularized Emscripten factory (or a pre-instantiated V8WasmExports object) before initializing V8, creating platforms, or allocating isolates and realms.

import {
  initV8,
  v8,
  createSingleThreadedDefaultPlatform,
  deletePlatform,
  createIsolate,
  createContext,
  IsolateScope,
  HandleScope,
  ContextScope,
  TryCatch,
  stringFromUtf8Checked,
  stringToUtf8,
  getTryCatchException,
  notifyIsolateShutdown,
} from '@browser-ports/v8-wasm';
import createV8Module from './v8_wasm_api.mjs';

await initV8({
  module: createV8Module,
  emscriptenOptions: { locateFile: (path: string) => `/wasm/${path}` },
});

const platform = createSingleThreadedDefaultPlatform();
v8.V8.initializePlatform(platform);
v8.V8.initialize();

using managed = createIsolate();
const { isolate } = managed;
using isoScope = new IsolateScope(isolate);

HandleScope.run(isolate, () => {
  const ctx = createContext(isolate);
  using ctxScope = new ContextScope(ctx);
  using tc = new TryCatch(isolate);

  const src = stringFromUtf8Checked(isolate, '20 + 22');
  const script = v8.Script.compile(ctx, src).toLocalChecked();
  const res = script.run(ctx);
  if (res.isEmpty() && tc.hasCaught()) {
    throw new Error(stringToUtf8(isolate, getTryCatchException(tc).toString(ctx).toLocalChecked()));
  }
  console.log(res.toLocalChecked().numberValue(ctx).fromJust()); // 42
});

notifyIsolateShutdown(platform, isolate);
deletePlatform(platform);

The v8 Namespace

To prevent collisions with JavaScript built-in globals, generated classes whose names collide with JS globals are exported at top level with a V8 prefix (V8Object, V8String, V8Function, V8Array, V8Number, V8Boolean, V8Symbol, V8BigInt, V8Date, V8RegExp, V8Map, V8Set, V8Promise, V8Proxy, V8ArrayBuffer, V8SharedArrayBuffer, V8DataView, V8JSON) and exposed under their exact upstream C++ names on the v8 namespace object (v8.Object, v8.String, v8.Function, v8.Script, v8.Isolate, etc.).

On this page