CodeSandbox
CodeSandbox provider for ComputeSDK - Execute code in CodeSandbox development environments.
Installation & Setup
Section titled “Installation & Setup”npm install @computesdk/codesandboxAdd your CodeSandbox credentials to a .env file:
CSB_API_KEY=your_codesandbox_api_keyimport { codesandbox } from '@computesdk/codesandbox';
const compute = codesandbox({
apiKey: process.env.CSB_API_KEY,
});
// Create sandbox
const sandbox = await compute.sandbox.create();
// Run a command
const result = await sandbox.runCommand('echo "Hello from CodeSandbox!"');
console.log(result.stdout); // "Hello from CodeSandbox!"
// Clean up
await sandbox.destroy();Configuration Options
Section titled “Configuration Options”interface CodesandboxConfig {
/** CodeSandbox API key - if not provided, will fallback to CSB_API_KEY environment variable */
apiKey?: string;
/** Template to use for new sandboxes */
templateId?: string;
/** Execution timeout in milliseconds */
timeout?: number;
}