diff --git a/apps/docs/get-started/nodejs.mdx b/apps/docs/get-started/nodejs.mdx index 6f17f8c..f41fc86 100644 --- a/apps/docs/get-started/nodejs.mdx +++ b/apps/docs/get-started/nodejs.mdx @@ -35,6 +35,8 @@ description: "Send your mail using unsend in NodeJS" Get the API key from the [Unsend dashboard](https://app.unsend.dev/api-keys) and initialize the SDK ```javascript + import { Unsend } from "unsend"; + const unsend = new Unsend({ apiKey: "us_12345" }); ``` diff --git a/packages/sdk/README.md b/packages/sdk/README.md new file mode 100644 index 0000000..a77344b --- /dev/null +++ b/packages/sdk/README.md @@ -0,0 +1,48 @@ +# Unsend SDK + +## Prerequisites + +- [Unsend API key](https://app.unsend.dev/api-keys) +- [Verified domain](https://app.unsend.dev/domains) + +## Installation + +### NPM + +```bash +npm install unsend +``` + +### Yarn + +```bash +yarn add unsend +``` + +### PNPM + +```bash +pnpm add unsend +``` + +### Bun + +```bash +bun add unsend +``` + +## Usage + +```javascript +import { Unsend } from "unsend"; + +const unsend = new Unsend({ apiKey: "us_12345" }); + +unsend.emails.send({ + to: "hello@acme.com", + from: "hello@company.com", + subject: "Unsend email", + html: "

Unsend is the best open source product to send emails

", + text: "Unsend is the best open source product to send emails", +}); +``` diff --git a/packages/sdk/src/unsend.ts b/packages/sdk/src/unsend.ts index 4dee288..67d4cda 100644 --- a/packages/sdk/src/unsend.ts +++ b/packages/sdk/src/unsend.ts @@ -27,7 +27,7 @@ export class Unsend { if (!this.key) { throw new Error( - 'Missing API key. Pass it to the constructor `new Unsend("re_123")`' + 'Missing API key. Pass it to the constructor `new Unsend("us_123")`' ); } }