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

# Quickstart

> Get your first sandbox running in minutes with the HopX JavaScript SDK - install, authenticate, execute code, see results. Complete quickstart guide for creating sandboxes, running JavaScript/TypeScript code, managing files, and cleaning up resources. Perfect for developers new to HopX. Includes async/await examples and best practices.

**Goal:** Create a sandbox, execute code, and see the output in under 5 minutes.\
**Prerequisites:** Node.js 18+, npm, HopX API key\
**Time:** \~5 minutes

This quickstart gets you from zero to your first successful code execution. Follow these steps in order.

## What You'll Learn

In this quickstart, you'll learn how to:

* Install and verify the JavaScript SDK
* Set up API key authentication
* Create a sandbox from a template
* Execute code in the sandbox using async/await
* Access execution results and output
* Clean up sandboxes properly

## Step 1: Install the SDK

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

## Step 1.5: Verify Installation

Verify the SDK is installed correctly:

```bash theme={null}
node -e "const { Sandbox } = require('@hopx-ai/sdk'); console.log('HopX SDK installed successfully')"
```

Expected output: `HopX SDK installed successfully`

## Step 2: Set Your API key

Set the `HOPX_API_KEY` environment variable:

```bash theme={null}
# Linux/macOS
export HOPX_API_KEY="your-API key-here"

# Windows (PowerShell)
$env:HOPX_API_KEY="your-API key-here"
```

<Note>
  Get your API key from [console.hopx.dev](https://console.hopx.dev) → Settings → API Keys
</Note>

## Step 3: Create and Run Your First Sandbox

Create a file `hello-HopX.js`:

```javascript theme={null}
import { Sandbox } from '@hopx-ai/sdk';

async function main() {
  // Create a sandbox (~100ms)
  const sandbox = await Sandbox.create({ template: 'code-interpreter' });

  // Execute code in the sandbox
  const result = await sandbox.runCode('print("Hello from HopX!")');

  // Print the output
  console.log(result.stdout);

  // Cleanup - delete the sandbox
  await sandbox.kill();
}

main().catch(console.error);
```

## Step 4: Run It

```bash theme={null}
node hello-HopX.js
```

<Note>
  If using ES modules, ensure your `package.json` has `"type": "module"`, or use `.mjs` extension.
</Note>

## Expected Output

```
Hello from HopX!
```

<Success>
  🎉 **Success!** You've created your first sandbox and executed code. The sandbox was automatically cleaned up after execution.
</Success>

## What Just Happened?

1. **`Sandbox.create()`** - Created a new sandbox from the `code-interpreter` template (Python environment)
2. **`sandbox.runCode()`** - Executed Python code in the sandbox
3. **`result.stdout`** - Retrieved the standard output from code execution
4. **`sandbox.kill()`** - Deleted the sandbox to free resources

## Related

* **[API Quickstart](/api/quickstart)** - Get started with the API
* **[Python SDK Quickstart](/sdk/python/quickstart)** - Python SDK equivalent
* **[Sandbox Class Reference](/sdk/javascript/sandbox)** - Complete SDK reference
* **[Creating Sandboxes](/core-concepts/sandboxes/creating)** - Learn more about sandbox creation

## Next Steps

Now that you have a working setup, explore more:

* **[Creating Sandboxes](/core-concepts/sandboxes/creating)** - Learn about different templates and options
* **[Code Execution](/core-concepts/code-execution/synchronous)** - Run Python, JavaScript, Bash, and more
* **[File Operations](/core-concepts/filesystem/reading)** - Read, write, and manage files in sandboxes
* **[CLI Quickstart](/cli/quickstart)** - Use HopX from the command line
* **[API Reference](/sdk/javascript/sandbox)** - Complete SDK documentation

## Quickstart Variations

<Note>
  For more advanced quickstart examples including error handling, environment variables, and TypeScript patterns, see the [Advanced Quickstart Guide](/sdk/javascript/advanced-quickstart) (coming soon).
</Note>

## Troubleshooting

**"API key required" error?**

* Verify `HOPX_API_KEY` is set: `echo $HOPX_API_KEY`
* Get your key at [console.hopx.dev](https://console.hopx.dev)

**"Template not found" error?**

* Use `template: 'code-interpreter'` (default Python template)
* See [Available Templates](/core-concepts/templates/listing) for options

**"Cannot find module" error?**

* Run `npm install @hopx-ai/sdk`
* Check Node.js version: `node --version` (should be 18+)

**Network timeout?**

* Check internet connection
* Verify firewall allows HTTPS (port 443)

For more help, see the [Troubleshooting Guide](/sdk/javascript/troubleshooting).
