Client
Install
One package, built on `@nextmail/sdk`, for the browser and every server runtime.
Install
pnpm add @nextmail/mailboximport { createClient } from '@nextmail/mailbox' const client = createClient({ accessToken: () => fetch('/api/mail-token').then((response) => response.text()),}) await client.emails.send({ from: '[email protected]', to: '[email protected]', 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. |
