---
title: "Install"
description: "One package, built on `@nextmail/sdk`, for the browser and every server runtime."
url: "https://nextmail.sh/docs/mailbox/install"
area: "Client"
category: "Getting started"
---

# Install

One package, built on `@nextmail/sdk`, for the browser and every server runtime.

## Install

**Install**

_pnpm_

```text
pnpm add @nextmail/mailbox
```

_npm_

```text
npm install @nextmail/mailbox
```

_yarn_

```text
yarn add @nextmail/mailbox
```

_bun_

```text
bun add @nextmail/mailbox
```

**send-email.ts**

```
import { createClient } from '@nextmail/mailbox'

const client = createClient({
  accessToken: () => fetch('/api/mail-token').then((response) => response.text()),
})

await client.emails.send({
  from: 'ada@acme.com',
  to: 'grace@example.com',
  subject: 'Tomorrow',
  html: '<p>Still on for ten?</p>',
})
```

`@nextmail/sdk` comes with it, so you add one package. If you use both in a project, they share one copy and the same error classes.

## Where it runs

In a browser, in a phone app and on Node 20+, Bun, Deno and Cloudflare Workers. It uses the global `fetch`, or the one you pass as `fetch`.

| Option | What it does |
| --- | --- |
| `accessToken` | Required. The token, or a function that returns it or a promise of it. |
| `baseUrl` | The API to call, when it is not the default. |
| `fetch` | The fetch to use instead of the global one. |
| `headers` | Headers to send with every request. |
| `maxRetries` | How many times a failed request is retried. |
| `timeoutMs` | How long a request may take. |
