Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7eba302
initial commit for sandboxes pags
thisisjofrank Dec 4, 2025
0ce35aa
Stub navigation in examples page
philhawksworth Dec 4, 2025
3954333
add sandbox example layout
philhawksworth Dec 4, 2025
943c0ab
examples
philhawksworth Dec 4, 2025
2bd0d3f
fix prod page link
philhawksworth Dec 4, 2025
e32f367
Merge branch 'main' of https://github.com/denoland/docs into sandboxes
thisisjofrank Dec 4, 2025
fbcac9a
updating sandboxes about and gettingstarted
thisisjofrank Dec 4, 2025
423043e
Merge branch 'sandboxes' of https://github.com/denoland/docs into san…
thisisjofrank Dec 4, 2025
b1c2014
fmt
thisisjofrank Dec 4, 2025
8e44730
updating docs
thisisjofrank Dec 4, 2025
78739b3
fmt
thisisjofrank Dec 4, 2025
1fe7cd7
Update link to getting stared
philhawksworth Dec 4, 2025
23a775d
Add links to API docs and examples
philhawksworth Dec 4, 2025
6c6d22a
Prefer console over app url
philhawksworth Dec 4, 2025
7dec30d
A bunch of sandbox examples
philhawksworth Dec 4, 2025
d803614
volumes docs
thisisjofrank Dec 4, 2025
0936993
volumes docs merge
thisisjofrank Dec 4, 2025
57fbaca
fix url mismatch
philhawksworth Dec 4, 2025
82a66a5
lifetimes
thisisjofrank Dec 4, 2025
d78d150
Merge branch 'sandboxes' of https://github.com/denoland/docs into san…
thisisjofrank Dec 4, 2025
ee6242a
expanded first steps
philhawksworth Dec 4, 2025
1cd88a1
updates after call
thisisjofrank Dec 4, 2025
6f00047
updates after call
thisisjofrank Dec 4, 2025
0f024ce
updating volumes
thisisjofrank Dec 5, 2025
6e84558
updating volumes
thisisjofrank Dec 5, 2025
313060e
update after meeting with ry
thisisjofrank Dec 5, 2025
ff9793b
update limits and regions
thisisjofrank Dec 5, 2025
c9de48d
Add structure to sidebar
philhawksworth Dec 5, 2025
8759218
update upload-and-run inline example
philhawksworth Dec 5, 2025
3841f6d
nav order
philhawksworth Dec 5, 2025
3b3fa91
even simpler run command
philhawksworth Dec 5, 2025
8cefbe9
adding subcommands
thisisjofrank Dec 5, 2025
862bdb1
update cli link
philhawksworth Dec 5, 2025
00ff641
UI screenshots
philhawksworth Dec 5, 2025
674725f
security
ry Dec 5, 2025
c9c2783
Remove allowNet references
ry Dec 5, 2025
d457e17
remove more references
ry Dec 5, 2025
0293866
extending lifetime
ry Dec 5, 2025
d9f704f
restructure for paths and hierarchy
philhawksworth Dec 5, 2025
2f4e1dd
reorder secondary nav
philhawksworth Dec 5, 2025
9854e8d
more nav shuffling
philhawksworth Dec 5, 2025
368270a
more comprehensive first sighting
philhawksworth Dec 5, 2025
9efee29
sidebar link fix
philhawksworth Dec 5, 2025
ba44ee2
another nav update
philhawksworth Dec 5, 2025
2796743
Remove promotion to deploying in Manage Deploy apps
philhawksworth Dec 5, 2025
bc61987
edit
ry Dec 8, 2025
652a54c
Update sandboxes/volumes.md
thisisjofrank Dec 9, 2025
379733e
Update sandboxes/volumes.md
thisisjofrank Dec 9, 2025
f2d2b17
Update sandboxes/volumes.md
thisisjofrank Dec 9, 2025
93d2502
Update sandboxes/volumes.md
thisisjofrank Dec 9, 2025
bf6e169
Update sandboxes/volumes.md
thisisjofrank Dec 9, 2025
15845e2
Mention Volumes in about intro
philhawksworth Dec 9, 2025
66eb2af
note ability to persist beyond connection
philhawksworth Dec 9, 2025
2e0e7e8
note traffic sent by all URL uses
philhawksworth Dec 9, 2025
54cc029
id is not an option. Add labels
philhawksworth Dec 9, 2025
f61c150
note private beta of this feature
philhawksworth Dec 9, 2025
16b1a19
update table
thisisjofrank Dec 9, 2025
8b21e87
options during create
philhawksworth Dec 9, 2025
66cafad
upload file clairifcation
philhawksworth Dec 9, 2025
3e0ae36
remove tips section
philhawksworth Dec 9, 2025
f668606
Merge branch 'main' into sandboxes
philhawksworth Dec 9, 2025
d6c2dd4
Update examples/sandboxes/command_cancellation.md
philhawksworth Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function (
const hrefIsInCurrentSection = (href: string, currentSection: string) => {
return href.includes(currentSection) ||
href === "/services/" &&
["deploy", "subhosting", "services"].includes(
["deploy", "subhosting", "services", "sandboxes"].includes(
currentSection,
);
};
Expand Down
1 change: 1 addition & 0 deletions _config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ site.copy("deploy/images");
site.copy("deploy/classic/images");
site.copy("deploy/kv/images");
site.copy("deploy/tutorials/images");
site.copy("sandboxes/images");
site.copy("runtime/fundamentals/images");
site.copy("runtime/getting_started/images");
site.copy("runtime/reference/images");
Expand Down
3 changes: 2 additions & 1 deletion _includes/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default function Layout(data: Lume.Data) {
"In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno";
const isServicesPage = data.url.startsWith("/deploy") ||
data.url.startsWith("/subhosting") ||
data.url.startsWith("/services");
data.url.startsWith("/services") ||
data.url.startsWith("/sandboxes");
const hasSubNav = isServicesPage;

return (
Expand Down
21 changes: 21 additions & 0 deletions _includes/sandbox-example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const layout = "doc.tsx";

export default function Raw(data: Lume.Data) {
return (
<>
<p className="italic">
<a href="https://deno.com/deploy/sandboxes/">Deno Sandboxes</a>{" "}
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.
</p>

{data.children}

<p className="my-8 block">
For more information about Sandboxes, see the{" "}
<a href="/sandboxes/">Sandboxes documentation</a>.
</p>
</>
);
}
2 changes: 2 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions deploy/_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export const SidebarNav = [
title: "Deno Deploy",
href: "/deploy/",
},
{
title: "Sandboxes",
href: "/sandboxes/",
},
{
title: "Deploy Classic",
href: "/deploy/classic/",
Expand Down
4 changes: 4 additions & 0 deletions deploy/classic/_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export const SidebarNav = [
title: "Deno Deploy",
href: "/deploy/",
},
{
title: "Sandboxes",
href: "/sandboxes/",
},
{
title: "Deploy Classic",
href: "/deploy/classic/",
Expand Down
85 changes: 85 additions & 0 deletions examples/_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,91 @@ export const sidebar = [
},
],
},
{
title: "Sandboxes",
items: [
{
title: "Evaluating JavaScript",
href: "/examples/sandboxes_evaluating_javascript/",
type: "example",
},
{
title: "Spawn a subprocess",
href: "/examples/sandboxes_spawn_subprocess/",
type: "example",
},
{
title: "Serve a web framework",
href: "/examples/sandboxes_web_framework/",
type: "example",
},
{
title: "Privide SSH access to a sandbox",
href: "/examples/sandboxes_ssh_access/",
type: "example",
},
{
title: "Intereactive JavaScript REPL",
href: "/examples/sandboxes_javascript_repl/",
type: "example",
},
{
title: "Provide a VSCode instance in a sandbox",
href: "/examples/sandboxes_vscode_instance/",
type: "example",
},
{
title: "Use template literals with variable interpolation",
href: "/examples/sandboxes_template_literals/",
type: "example",
},
{
title: "Error handling",
href: "/examples/sandboxes_error_handling/",
type: "example",
},
{
title: "Error handling with custom error classes",
href: "/examples/sandboxes_custom_error_classes/",
type: "example",
},
{
title: "Command cancellation",
href: "/examples/sandboxes_command_cancellation/",
type: "example",
},
{
title: "Access string and binary output",
href: "/examples/sandboxes_access_output/",
type: "example",
},
{
title: "Set and get environment variables",
href: "/examples/sandboxes_environment_variables/",
type: "example",
},
{
title: "Stream output to a local file",
href: "/examples/sandboxes_stream_output/",
type: "example",
},
{
title: "Upload files and directories to a sandbox",
href: "/examples/sandboxes_upload_files/",
type: "example",
},
{
title: "Control sandbox lifetime",
href: "/examples/sandboxes_lifetime_control/",
type: "example",
},
{
title: "Configure sandbox memory",
href: "/examples/sandboxes_memory/",
type: "example",
},
],
},
{
title: "Testing",
items: [
Expand Down
24 changes: 24 additions & 0 deletions examples/sandboxes/access_output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Access string and binary output"
description: "Learn how to access string and binary output from commands in a sandbox."
url: /examples/sandboxes_access_output/
layout: sandbox-example.tsx
---

You can access string and binary output from commands in a sandbox.

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

await using sandbox = await Sandbox.create();

// Get both string and binary data
const result = await sandbox.sh`cat binary-file.png`
.stdout("piped");
console.log("Binary length:", result.stdout!.length);
console.log("Text length:", result.stdoutText!.length);

// Use the binary data
import fs from "node:fs";
fs.writeFileSync("output.png", result.stdout!);
```
30 changes: 30 additions & 0 deletions examples/sandboxes/command_cancellation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: "Command cancellation"
description: "Learn how to cancel commands in a sandbox."
url: /examples/sandboxes_command_cancellation/
layout: sandbox-example.tsx
---

You can cancel commands in a sandbox using the `KillController` class.

```ts
import { KillController, Sandbox } from "@deno/sandbox";

await using sandbox = await Sandbox.create();

// Start a long-running command
const controller = new KillController();
const cmd = sandbox.sh`sleep 30`.signal(controller.signal);
const promise = cmd.text();

// Cancel after 2 seconds
setTimeout(() => {
controller.kill(); // Kill the process
}, 2000);

try {
await promise;
} catch (error) {
console.log("Command was cancelled:", error);
}
```
23 changes: 23 additions & 0 deletions examples/sandboxes/custom_error_classes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "Error handling with custom error classes"
description: "Learn how to handle errors with custom error classes in a sandbox."
url: /examples/sandboxes_custom_error_classes/
layout: sandbox-example.tsx
---

You can handle errors with custom error classes in a sandbox.

```ts
import { Sandbox, SandboxCommandError } from "@deno/sandbox";

await using sandbox = await Sandbox.create();

try {
await sandbox.sh`exit 42`;
} catch (error) {
if (error instanceof SandboxCommandError) {
console.log("Exit code:", error.code); // → 42
console.log("Error message:", error.message);
}
}
```
23 changes: 23 additions & 0 deletions examples/sandboxes/environment_variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "Set and get environment variables"
description: "Learn how to set and get environment variables in a sandbox."
url: /examples/sandboxes_environment_variables/
layout: sandbox-example.tsx
---

You can use the `sandbox.env.set()` method to set environment variables in a
sandbox.

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

await using sandbox = await Sandbox.create();

// Set environment variables
await sandbox.env.set("API_KEY", "secret-key-123");
await sandbox.env.set("NODE_ENV", "production");

// Use them in a script
const apiKey = await sandbox.sh`echo $API_KEY`.text();
console.log("API_KEY:", apiKey.trim());
```
27 changes: 27 additions & 0 deletions examples/sandboxes/error_handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "Error handling"
description: "Learn how to handle errors in a sandbox."
url: /examples/sandboxes_error_handling/
layout: sandbox-example.tsx
---

Commands in a sandbox throw by default on non-zero exit. You can use the
`noThrow()` method to handle errors manually.

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

await using sandbox = await Sandbox.create();

// Commands throw by default on non-zero exit
try {
await sandbox.sh`exit 1`;
} catch (error) {
console.log("Command failed:", error);
}

// Use noThrow() to handle errors manually
const result = await sandbox.sh`exit 1`.noThrow();
console.log("Exit code:", result.status.code); // → 1
console.log("Success:", result.status.success); // → false
```
21 changes: 21 additions & 0 deletions examples/sandboxes/evaluating_javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "Evaluating JavaScript"
description: "Learn how to evaluate JavaScript code in a sandbox."
url: /examples/sandboxes_evaluating_javascript/
layout: sandbox-example.tsx
---

You can evaluate JavaScript code in a sandbox using the `eval` function.

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

await using sandbox = await Sandbox.create();

const result = await sandbox.eval(`
const a = 1;
const b = 2;
a + b;
`);
console.log("result:", result);
```
27 changes: 27 additions & 0 deletions examples/sandboxes/javascript_repl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "Intereactive JavaScript REPL"
description: "Learn how to provide an interactive JavaScript REPL in a sandbox."
url: /examples/sandboxes_javascript_repl/
layout: sandbox-example.tsx
---

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

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

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

await using sandbox = await Sandbox.create();

// Start a JavaScript REPL
const repl = await sandbox.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
```
Loading