# Add high-performance video to your TypeScript or Node.js application

Use the official Mux TypeScript SDK (`@mux/ts`) to call the Mux API from Node.js, Deno, Bun, or edge runtimes. The SDK handles authentication and wraps each API endpoint in typed methods.

The Mux TypeScript SDK wraps the Mux REST API in typed methods you can call from TypeScript or JavaScript. It runs on Node.js, Deno, Bun, Cloudflare Workers, and Vercel Edge Runtime. You can create assets, manage live streams, and query Mux Data without manual HTTP requests.

## Installation

Add a dependency on the `@mux/ts` package via npm or yarn.

```bash
npm install @mux/ts
```

Already using `@mux/mux-node`? It's the same SDK under its previous name, and existing installs keep working. We recommend switching to `@mux/ts`. If you're already on version 15, switching is a dependency and import rename. If you're on an earlier version, upgrade to 15 first; it includes breaking changes, covered in the [migration guide](https://github.com/muxinc/mux-ts/blob/main/MIGRATION.md).

## Quickstart

To start, you'll need a Mux access token. Once you've got that, you're off to the races!

```javascript
import Mux from '@mux/ts';
const mux = new Mux({
  tokenId: process.env.MUX_TOKEN_ID,
  tokenSecret: process.env.MUX_TOKEN_SECRET
});

const asset = await mux.video.assets.create({
  input: [{ url: 'https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4' }],
  playback_policy: ['public'],
});
```

## Runtimes

With no arguments, `new Mux()` reads `MUX_TOKEN_ID` and `MUX_TOKEN_SECRET` from the environment. How you provide them depends on where your code runs.

### Node.js

Node.js 20 or later is supported, with either ES modules or CommonJS:

```javascript
import Mux from '@mux/ts';

const mux = new Mux();
```

```javascript
const Mux = require('@mux/ts');

const mux = new Mux();
```

### Deno and Bun

In Deno, import the package with an `npm:` specifier and run with `--allow-env` so the SDK can read your credentials, and `--allow-net` so it can reach the Mux API:

```javascript
import Mux from 'npm:@mux/ts';

const mux = new Mux();
```

Bun works the same way as Node.js. Install the package with `bun add @mux/ts`.

### Cloudflare Workers and Vercel Edge

Cloudflare Workers expose secrets as bindings rather than environment variables, so pass them to the client explicitly:

```javascript
import Mux from '@mux/ts';

export default {
  async fetch(request, env) {
    const mux = new Mux({ tokenId: env.MUX_TOKEN_ID, tokenSecret: env.MUX_TOKEN_SECRET });
    const assets = await mux.video.assets.list();
    return Response.json(assets.data);
  },
};
```

On Vercel Edge Runtime, `process.env` is available, so `new Mux()` works as it does in Node.js.

## Full documentation

Check out the [Mux TypeScript SDK docs](https://github.com/muxinc/mux-ts) for more information.
