Menu

Vercel Sandbox examples

Last updated October 23, 2025

Vercel Sandbox is available in Beta on all plans

Learn how to use the Sandbox SDK through real-life examples.

In this example, you create an isolated environment from a private Git repository by authenticating with a GitHub personal access token or GitHub App token, and run a simple command inside the sandbox.

The method initializes the environment with the provided repository and configuration options, including authentication credentials, , and exposed . Once created, you can execute commands inside the sandboxed environment using .

There are several ways to authenticate with private GitHub repositories.

Fine-grained tokens provide repository-specific access and enhanced security:

  1. Go to GitHub Settings → Developer settings → Personal access tokens → Fine-grained tokens
  2. Click Generate new token
  3. Configure the token:
    • Token name: Give it a descriptive name (e.g., "Vercel Sandbox Access")
    • Expiration: Set an appropriate expiration date
    • Resource owner: Select your account or organization
    • Repository access: Choose "Selected repositories" and select your private repo
    • Repository permissions: Grant at minimum:
      • Contents: Read (to clone the repository)
      • Metadata: Read (for basic repository information)
  4. Click "Generate token" and copy the token
  5. Set it as an environment variable and run your sandbox script:

You can install system packages using the system package manager:

You can find the list of available packages on the Amazon Linux documentation.

In the example, allows the command to run with elevated privileges.

You can extend the timeout of a running sandbox using the method, which takes a duration in milliseconds:

You can extend the timeout as many times as you'd like, until the max timeout for your plan has been reached.


Was this helpful?

supported.