Prerequisites
Export your Archil API key and region, install the Archil and Vercel Sandbox SDKs, and link the directory to a Vercel project with the Vercel CLI. On your machine,@vercel/sandbox authenticates as the linked project.
Mount a disk
First, create a disk. You only do this once:setup.ts
eval "$(npx tsx setup.ts)" to export the disk ID and the disk’s mount token, which grants access to this disk only. In a Vercel Function, store both as environment variables instead.
Now start a sandbox in the Vercel region next to the disk, install the archil client, mount the disk at /mnt/archil, and write a file. The commands run as root, and the token is passed only to the mount command:
mount.ts
archil client buffers recent writes, so the script unmounts before it stops the sandbox: archil unmount returns once every write has reached the disk. Run npx tsx mount.ts twice. Each run starts a new sandbox, and the second one finds the line the first one wrote:
--shared, and see Sharing disks.
Read it from anywhere
Both sandboxes are gone, and the file is still on the disk. Read it from your own machine or app with the SDK:read.ts
Clean up
Delete the disk with thedisk CLI. The sandboxes already stopped at the end of each run.
Next steps
- TypeScript SDK: read, write, and search the disk without mounting it.
- Persistent sandboxes: Archil’s own sandboxes, with the disk mounted for you.