T
traeai
登录
返回首页
Vercel News

Sandbox persistence is now GA

9.0Score

TL;DR · AI 摘要

Vercel 宣布其沙盒功能现在正式可用,支持自动保存和恢复文件系统状态,无需手动管理快照。

核心要点

  • Vercel 沙盒默认启用持久化功能,无需手动管理快照。
  • 可以通过名称创建、检索或恢复沙盒,Vercel 自动管理会话启动和关闭。
  • 持久化沙盒会消耗额外的存储空间,非持久化沙盒可以在会话结束时丢弃文件系统。

结构提纲

按章节快速跳转。

  1. Vercel 宣布其沙盒功能现在正式可用,支持自动保存和恢复文件系统状态。

  2. 通过调用 `Sandbox.create()` 并设置 `name` 参数,可以创建一个带有持久化功能的沙盒。

  3. 可以通过设置 `persistent: false` 来创建一个不带持久化功能的临时沙盒。

  4. 任何对停止沙盒的调用都会自动从最近的快照开始一个新的会话。

  5. 包括 `Sandbox.fork()`、`Sandbox.getOrCreate()`、`Sandbox.delete()` 等新功能。

  6. 升级到最新版本的 SDK 和 CLI 以使用默认的持久化沙盒功能。

思维导图

用一张图看清主题之间的关系。

查看大纲文本(无障碍 / 无 JS 友好)
  • Vercel 沙盒持久化功能
    • 创建持久化沙盒
      • 代码示例
    • 创建临时沙盒
      • 代码示例
    • 恢复持久化沙盒
      • 代码示例
    • 其他改进
      • Sandbox.fork()
      • Sandbox.getOrCreate()
      • Sandbox.delete()
    • 开始使用
      • SDK 升级
      • CLI 升级

金句 / Highlights

值得收藏与分享的关键句。

#Vercel#沙盒#持久化#开发工具
打开原文

2 min read

May 26, 2026

Vercel Sandboxes now automatically save and restore filesystem state between sessions. Persistence is on by default, meaning no snapshots to manage or state to track manually.

Each sandbox has a durable, customizable name that acts as a unique reference in your project. You can create, retrieve, or resume a sandbox by name. Vercel spins sessions up and down automatically, without interrupting your workflow.

[Link to heading](https://vercel.com/changelog/sandbox-persistence-is-now-ga#create-a-persistent-sandbox)Create a persistent sandbox

When you call Sandbox.create(), persistence is enabled by default:

import { Sandbox } from "@vercel/sandbox";// Filesystem is snapshotted automaticallyconst sandbox = await Sandbox.create({ name: "my-sandbox" }); await sandbox.runCommand("npm", ["install"]);await sandbox.stop();

Create a sandbox with persistence on by default

Each automatic snapshot consumes snapshot storage, which is billed separately from compute. For ephemeral workloads, opt out of persistence to minimize storage costs:

import { Sandbox } from "@vercel/sandbox";const sandbox = await Sandbox.create({ persistent: false });// Or update an existing sandbox.await sandbox.update({ persistent: false });

Create an ephemeral sandbox

To opt out of persistence with the CLI, pass --non-persistent to sandbox create. Non-persistent sandboxes discard their filesystem when the session ends.

[Link to heading](https://vercel.com/changelog/sandbox-persistence-is-now-ga#resume-a-persistent-sandbox)Resume a persistent sandbox

Resuming is automatic. Any call on a stopped sandbox, like runCommand() or writeFiles(), starts a new session from the most recent snapshot.

import { Sandbox } from "@vercel/sandbox";const resumedSandbox = await Sandbox.get({ name: "my-sandbox" });// Automatically resumes the sandbox.await resumedSandbox.runCommand("npm", ["test"]);

Automatically resume a stopped sandbox

[Link to heading](https://vercel.com/changelog/sandbox-persistence-is-now-ga#other-improvements)Other improvements

  • Sandbox.fork(): Create a new sandbox from an existing one
  • Sandbox.getOrCreate(): Idempotent retrieve-or-create for long-lived sandboxes
  • Sandbox.delete(): Permanently delete a sandbox
  • Richer sandbox.stop(): Returns snapshot metadata plus active-CPU and network-transfer totals
  • Lifecycle hooks: onCreate and onResume hooks for create, get, and getOrCreate
  • Tags: Assign custom properties to sandboxes for multi-tenant tracking

[Link to heading](https://vercel.com/changelog/sandbox-persistence-is-now-ga#get-started-)Get started

Upgrade to the latest version to create persistent sandboxes by default:

  • pnpm install @vercel/sandbox@latest # SDK
  • pnpm install -g sandbox@latest # CLI

Learn more about persistent sandboxes in the documentation.

AI 可能会生成不准确的信息,请核实重要内容

Sandbox persistence is now GA | Vercel News | traeai