# Playground

Daytona provides an interactive environment ("playground") in the [Daytona Dashboard ↗](https://app.daytona.com/dashboard) for writing TypeScript against the [TypeScript SDK](https://www.daytona.io/docs/en/v2/typescript-sdk.md) and running it in your browser. It bundles the SDK and provides a code editor with type checking and completions, an examples browser, and a console for program output. You do not install anything locally or handle an API key.

## Use cases

The playground is used to run TypeScript SDK code without a local setup.

- **SDK trials**: SDK calls run in a web worker inside the browser. The playground provides the API key and endpoints, so there is nothing to install or configure.
- **Learning the SDK**: the editor checks types and completes names from the SDK's type definitions. A new user sees the available methods and their parameters while writing the code.
- **Sandbox lifecycle**: a program creates, lists, and deletes sandboxes and prints the state of each. The output shows how a sandbox moves between states.
- **Commands and files**: a program runs a shell command in a sandbox, writes and reads files, and prints the results to the console.
- **Image builds**: a program builds an image from an inline Dockerfile and creates a sandbox from it. The Dockerfile is checked before it moves into an application.
- **Operation sequences**: a sequence of sandbox operations runs against the Daytona API and is checked before it goes into an application.
- **Starting points**: a curated example runs as it is, then changes, then moves into your own application. The examples cover the sandbox lifecycle, commands, files, and images.

## Access from Dashboard

1. Go to [Daytona Dashboard ↗](https://app.daytona.com/dashboard)
2. Click <Button>Playground</Button> in the sidebar to access the playground

## Writing code

Programs are plain TypeScript that import the Daytona SDK. Top-level await is supported, and the editor provides type checking and completions from the SDK's type definitions.

```typescript
import { Daytona } from '@daytona/sdk'

// The playground provides the API key and endpoints for you — no config needed.
const daytona = new Daytona()

async function main() {
  console.log('Creating a sandbox…')
  const sandbox = await daytona.v2.create()
  console.log('Sandbox ready:', sandbox.id, '(', sandbox.state, ')')

  console.log('Cleaning up…')
  await daytona.v2.delete(sandbox)
  console.log('Done.')
}

await main()
```

## Running code

1. Go to [Daytona Playground ↗](https://app.daytona.com/dashboard/playground) to access the playground.
2. Click <Button>Run</Button> to compile the program and execute it in a web worker inside your browser.
3. Click <Button>Stop</Button> to terminate a run in progress. Stopping a run does not clean up resources it already created. Any sandbox created mid-run may still exist — delete it if needed.

## Examples

| Example                     | Description                                                                              |
| --------------------------- | ---------------------------------------------------------------------------------------- |
| **Hello sandbox**           | Create a sandbox, print its id and state, then delete it.                                |
| **Lifecycle**               | Create, list and delete sandboxes; inspect state transitions.                            |
| **Run a command**           | Execute a shell command inside a sandbox and read its output.                            |
| **File operations**         | Write, list and read files in a sandbox via the toolbox file system API.                 |
| **Snapshots**               | Create an image snapshot alias and launch a sandbox from it.                             |
| **Build from a Dockerfile** | Build an image snapshot from an inline Dockerfile, then launch a sandbox from it.        |

For more information on the operations used in the examples, see [sandboxes](https://www.daytona.io/docs/en/v2/sandboxes.md), [process execution](https://www.daytona.io/docs/en/v2/process-execution.md), [code execution](https://www.daytona.io/docs/en/v2/code-execution.md), [file system operations](https://www.daytona.io/docs/en/v2/file-system-operations.md), and [snapshots](https://www.daytona.io/docs/en/v2/snapshots.md).