---
title: "Install"
description: "One package, no dependencies, every server runtime."
url: "https://nextmail.sh/docs/sdk/install"
area: "TypeScript"
category: "Getting started"
---

# Install

One package, no dependencies, every server runtime.

## Install

> The current release is `0.0.1`. Every documented operation has a method, the package’s parity check fails the build when one goes missing, and the API it wraps is on in every environment.

**Install**

_pnpm_

```text
pnpm add @nextmail/sdk
```

_npm_

```text
npm install @nextmail/sdk
```

_yarn_

```text
yarn add @nextmail/sdk
```

_bun_

```text
bun add @nextmail/sdk
```

_deno_

```text
deno add npm:@nextmail/sdk
```

**send-email.ts**

```
import { init, nextmail } from '@nextmail/sdk'

init({ apiKey: process.env.NEXTMAIL_API_KEY })

const email = await nextmail.emails.send({
  from: 'Acme Billing <billing@acme.com>',
  to: 'ada@example.com',
  subject: 'Your September invoice',
  html: '<p>Invoice attached.</p>',
})

console.log(email.id, email.status)
```

`init` configures the shared `nextmail` client once, and every module that imports `nextmail` afterwards gets that client. Skip it and the first call builds the client from `NEXTMAIL_API_KEY` instead.

> `send()` resolving does not mean the message has gone. A scheduled or cancellable send comes back `queued` or `scheduled` and settles later. Read `status`, not the fact that the promise resolved.

## Where it runs

Zero runtime dependencies, on Node 20+, Bun, Deno and Cloudflare Workers. It uses the global `fetch` and nothing else, and you can hand it your own.

> ESM and CommonJS both ship, each with its own type declarations, so `import { nextmail } from '@nextmail/sdk'` and `const { nextmail } = require('@nextmail/sdk')` both work.

> Not in a browser. The client carries a workspace API key that can send mail and read the mailbox, so it refuses to start where `window` and `document` exist. Disposable inboxes are the exception: `createTempMail()` needs no key and runs in a page.

> This is the TypeScript and JavaScript client. Python, Ruby, PHP, Go, Java and C# have packages of their own with the same methods: `nextmail` on PyPI, the `nextmail` gem, `nextmail/sdk` on Packagist, `github.com/bfzli/nextmail-go`, `sh.nextmail:nextmail` on Maven Central and `Nextmail` on NuGet. From any other language the API is plain HTTP and JSON: the quickstart carries a working request in eight languages, and the OpenAPI document generates a client in most of the rest.
