import { Hyperbrowser } from "@hyperbrowser/sdk";
const client = new Hyperbrowser({
apiKey: process.env.HYPERBROWSER_API_KEY,
});
// 1) Create volume
const volume = await client.volumes.create({ name: "my-workspace" });
// 2) Create sandbox with mounted volume
const sandbox = await client.sandboxes.create({
imageName: "node",
mounts: {
"/mnt/workspace": {
id: volume.id,
type: "rw",
},
},
});
// 3) Write/read through mounted path
await sandbox.files.writeText("/mnt/workspace/hello.txt", "hello from volume");
const text = await sandbox.files.readText("/mnt/workspace/hello.txt");
console.log(text);