Skip to main content

Intereactive JavaScript REPL

Deno Sandbox provide a sandboxed environment for evaluating JavaScript code. This is useful for evaluating code that is not trusted or for testing code that is not safe to run in the main runtime.

The sandbox.deno.repl() method can be used to provide an interactive Deno REPL in a sandbox.

This example shows how to start a Deno REPL in a sandbox and execute code interactively.

import { Sandbox } from "@deno/sandbox";

await using sandbox = await Sandbox.create();

// Start a Deno REPL
const repl = await sandbox.deno.repl();

// Execute code interactively, maintaining state
await repl.eval("const x = 42;");
await repl.eval("const y = 8;");
const result = await repl.eval("x + y");
console.log("result:", result); // 50

For more information, see the Deno Sandbox documentation.

Did you find what you needed?

Privacy policy