### Project Setup and Installation with PNPM Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=dependencies Commands to create a new project directory, navigate into it, initialize a Node.js project using pnpm, and add necessary dependencies and types for @vercel/sandbox and ms. ```bash mkdir sandbox-test cd sandbox-test pnpm init pnpm add @vercel/sandbox ms pnpm add -D @types/ms @types/node ``` -------------------------------- ### Install Golang with Sudo using Vercel Sandbox Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=dependencies Demonstrates how to install the Go programming language using the `dnf install` command with sudo privileges within the Vercel Sandbox environment. It highlights the use of the `Sandbox.create()` and `sandbox.runCommand()` methods. ```typescript import { Sandbox } from "@vercel/sandbox"; const sandbox = await Sandbox.create(); await sandbox.runCommand({ cmd: "dnf", args: ["install", "-y", "golang"], sudo: true, }); ``` -------------------------------- ### Running a Next.js Dev Server in Vercel Sandbox Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=dependencies A TypeScript script that uses the @vercel/sandbox package to create an isolated environment, clone a Next.js example repository, install dependencies, run the development server, and open it in the browser. ```typescript import ms from "ms"; import { Sandbox } from "@vercel/sandbox"; import { setTimeout } from "timers/promises"; import { spawn } from "child_process"; async function main() { const sandbox = await Sandbox.create({ source: { url: "https://github.com/vercel/sandbox-example-next.git", type: "git", }, resources: { vcpus: 4 }, timeout: ms("5m"), ports: [3000], runtime: "node22", }); console.log(`Installing dependencies...`); const install = await sandbox.runCommand({ cmd: "npm", args: ["install", "--loglevel", "info"], stderr: process.stderr, stdout: process.stdout, }); if (install.exitCode != 0) { console.log("installing packages failed"); process.exit(1); } console.log(`Starting the development server...`); await sandbox.runCommand({ cmd: "npm", args: ["run", "dev"], stderr: process.stderr, stdout: process.stdout, detached: true, }); await setTimeout(500); spawn("open", [sandbox.domain(3000)]); } main().catch(console.error); ``` -------------------------------- ### Install Vercel Sandbox Dependencies (pnpm) Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=readme This snippet demonstrates how to install the @vercel/sandbox package and its related types using the pnpm package manager. ```bash pnpm init pnpm add @vercel/sandbox ms pnpm add -D @types/ms @types/node ``` -------------------------------- ### Installed System Packages Source: https://www.npmjs.com/package/%40vercel/sandbox List of additional packages installed on the base Amazon Linux 2023 system within the Vercel Sandbox environment. ```bash bind-utils bzip2 findutils git gzip iputils libicu libjpeg libpng ncurses-libs openssl openssl-libs procps tar unzip which whois zstd ``` -------------------------------- ### Sandbox Creation with Access Token Authentication Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=dependencies Example of creating a Vercel Sandbox instance using explicit team ID, project ID, and access token for authentication. This method is useful when VERCEL_OIDC_TOKEN is not available. ```typescript const sandbox = await Sandbox.create({ teamId: process.env.VERCEL_TEAM_ID!, projectId: process.env.VERCEL_PROJECT_ID!, token: process.env.VERCEL_TOKEN!, source: { url: "https://github.com/vercel/sandbox-example-next.git", type: "git", }, resources: { vcpus: 4 }, // Defaults to 5 minutes. The maximum is 5 hours for Pro/Enterprise, and 45 minutes for Hobby. timeout: ms("5m"), ports: [3000], runtime: "node22", }); ``` -------------------------------- ### Link project to Vercel and pull environment variables Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=versions CLI commands to link the local project to a Vercel project and fetch environment variables, which are often needed for authentication or configuration. ```bash vercel link vercel env pull ``` -------------------------------- ### Executing the Sandbox Script Locally Source: https://www.npmjs.com/package/%40vercel/sandbox_activetab=dependencies Command to run the TypeScript script locally, using environment variables from a .env.local file and enabling experimental type stripping. ```bash node --env-file .env.local --experimental-strip-types ./next-dev.ts ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.