--- title: Persistent sandboxes description: One Modal sandbox whose filesystem outlives its sessions, resumed from a Worker. --- import Timeline from "../../../../components/diagrams/Timeline.astro"; A **persistent sandbox** is one sandbox whose files outlive the container that runs it. It runs in **sessions**: each one up to an hour, paused after five idle minutes, and resumed with the files the last one left. ## Sessions come and go, the files stay ## Declare a box ```typescript title="src/DevBox.ts" import * as Modal from "@alchemy.run/modal"; import { Coder, Warm } from "./Coder.ts"; export const DevBox = Modal.PersistentSandbox("DevBox", { app: Coder, image: Warm, workdir: "/work" }); ``` ## Resume it from a Worker ```typescript // construction phase const box = yield* Modal.ConnectSandbox(DevBox); // in fetch: const session = yield* box.session(); const status = yield* session.exec("git status"); ``` `session()` returns the running session, or resumes the box from its last session's files. ## Create one per user while your app runs ```typescript const box = yield* sandboxes.createPersistent({ image: "node:22-bookworm" }); // store box.persistentSandboxId with the user ``` Persistent sandboxes are experimental on Modal: no names, GPUs, `env` or tags yet.