Skip to content

Latest commit

 

History

History
79 lines (64 loc) · 1.6 KB

File metadata and controls

79 lines (64 loc) · 1.6 KB
description Install and use the CodeSandbox provider for ComputeSDK to create sandboxes and run commands in CodeSandbox environments.
layout
width title description tableOfContents outline pagination metadata tags actions
default
visible
true
visible
visible
true
visible
true
visible
true
visible
true
visible
true
visible
true
tags
tag primary
benchmarked
true

CodeSandbox

{% embed url="https://www.computesdk.com/benchmarks/sandboxes/codesandbox/" %}

CodeSandbox provider for ComputeSDK - Execute code in CodeSandbox development environments.

Installation & Setup

npm install @computesdk/codesandbox

Add your CodeSandbox credentials to a .env file:

CSB_API_KEY=your_codesandbox_api_key

Usage

import { 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

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;
  /** Default runtime environment, e.g. 'node', 'python' */
  runtime?: string;
  /** Execution timeout in milliseconds */
  timeout?: number;
}