Skip to content
sandbox-workers
Esc
navigateopen⌘Jpreview
On this page

JavaScript

Execute code with SpiderMonkey 147 (goccy/spidermonkey-wasm v0.2.6) inside a dedicated Wasm Worker.

Package: @sandbox-workers/javascript. Code is a script: the value of the last expression is the result. Supports await, promises, modern JavaScript syntax, and Intl. There are no Web builtins (no fetch, URL, Response, timers); ES modules, Node/npm resolution, and networking are also unavailable. BigInt results become strings ending in n.

TypeScript is accepted automatically — no language option, no separate mode. Code is parsed as JavaScript first, so valid JavaScript never changes meaning; only code that fails to parse as JavaScript falls back to stripping TypeScript-only syntax (types, interface, generics, as/satisfies, enum, namespace, parameter properties). Types are stripped, not checked — a type error still runs like any other JavaScript mistake. import/export remain unsupported in both dialects.

Deploy

Deploy to Cloudflare

Or, after npm publication:

pnpm dlx @sandbox-workers/cli init javascript my-sandbox

See deployment setup and Service Bindings. The template requires a Paid plan and creates no public URL.

Example

Env vars:

{ "NAME": "world" }

Code:

const name = process.env.NAME ?? "world";
console.log(`Hello, ${name}!`);
({
  greeting: `Hello, ${name}!`,
  engine: "SpiderMonkey inside WebAssembly",
});

Every request gets a fresh engine instance. State does not persist between executions. Consult limits for fuel, memory, and output budgets.

License notice

Before use or redistribution, review this runtime’s LICENSE and THIRD_PARTY_NOTICES.md. Bundled interpreters retain their upstream licenses. The package includes the applicable notices in its licenses/ directory.