> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boxlite.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js Quick Start

> Get up and running with BoxLite Node.js SDK in 5 minutes.

## Installation

```bash theme={null}
npm install @boxlite-ai/boxlite
```

**Requirements:**

* Node.js 18 or later
* Platform with hardware virtualization (see [Installation](/getting-started/index#system-requirements))

**Verify Installation:**

```javascript theme={null}
import { SimpleBox } from '@boxlite-ai/boxlite';
console.log('BoxLite loaded successfully');
```

## Basic Execution

<Steps>
  <Step title="Create a file hello.js">
    ```javascript theme={null}
    import { SimpleBox } from '@boxlite-ai/boxlite';

    async function main() {
      const box = new SimpleBox({ image: 'python:slim' });
      try {
        const result = await box.exec('python', '-c', "print('Hello from BoxLite!')");
        console.log(result.stdout);
      } finally {
        await box.stop();
      }
    }

    main();
    ```
  </Step>

  <Step title="Run it">
    ```bash theme={null}
    node hello.js
    ```
  </Step>
</Steps>

**What's happening:**

1. BoxLite pulls the `python:slim` OCI image (first run only)
2. Creates a lightweight VM with the image
3. Executes the Python command inside the VM
4. Streams output back to your application
5. Cleans up when `stop()` is called

## TypeScript 5.2+ (Async Disposal)

```typescript theme={null}
import { SimpleBox } from '@boxlite-ai/boxlite';

async function main() {
  await using box = new SimpleBox({ image: 'alpine:latest' });
  const result = await box.exec('echo', 'Hello!');
  console.log(result.stdout);
  // Box automatically stopped when leaving scope
}

main();
```

## Code Execution (AI Agents)

<Steps>
  <Step title="Create a file codebox.js">
    ```javascript theme={null}
    import { CodeBox } from '@boxlite-ai/boxlite';

    async function main() {
      const codebox = new CodeBox();
      try {
        // Execute untrusted code safely
        const code = `
    import requests
    response = requests.get('https://api.github.com/zen')
    print(response.text)
    `;
        const result = await codebox.run(code);
        console.log(result);
      } finally {
        await codebox.stop();
      }
    }

    main();
    ```
  </Step>

  <Step title="Run it">
    ```bash theme={null}
    node codebox.js
    ```
  </Step>
</Steps>

**What's happening:**

1. CodeBox automatically installs required packages (requests)
2. Executes the code in complete isolation
3. Returns the output as a string
4. Your host system remains completely safe

## Running Examples

BoxLite includes 5 Node.js examples:

<Steps>
  <Step title="Clone and build the SDK">
    ```bash theme={null}
    # Clone the repository
    git clone https://github.com/boxlite-ai/boxlite.git
    cd boxlite/sdks/node

    # Build the SDK
    npm install && npm run build
    npm link
    ```
  </Step>

  <Step title="Run the examples">
    ```bash theme={null}
    cd ../../examples/node
    npm link @boxlite-ai/boxlite

    node simplebox.js
    node codebox.js
    node browserbox.js
    node computerbox.js
    node interactivebox.js
    ```
  </Step>
</Steps>

**Examples overview:**

| # | Example               | Description                                       |
| - | --------------------- | ------------------------------------------------- |
| 1 | **simplebox.js**      | Basic command execution                           |
| 2 | **codebox.js**        | Python code execution sandbox                     |
| 3 | **browserbox.js**     | Browser automation with CDP                       |
| 4 | **computerbox.js**    | Desktop automation (mouse, keyboard, screenshots) |
| 5 | **interactivebox.js** | Interactive terminal sessions                     |

## Next Steps

<CardGroup cols={2}>
  <Card title="Core concepts" icon="lightbulb" href="/getting-started/core-concepts">
    Understand the different box types (SimpleBox, CodeBox, BrowserBox, and more), lifecycle, images, and resource configuration.
  </Card>

  <Card title="Execute AI-generated code" icon="code" href="/tutorials/code-execution">
    Learn to use CodeBox for safe code execution — auto-install packages, run untrusted code, and capture output.
  </Card>

  <Card title="Node.js SDK Reference" icon="book" href="/reference/nodejs/index">
    Complete API reference for SimpleBox, CodeBox, BrowserBox, ComputerBox, and more.
  </Card>
</CardGroup>
