From 14557a96ac8e69fc0f2e6c6f7d1cd5d3d8c69b67 Mon Sep 17 00:00:00 2001 From: KM Koushik Date: Sat, 17 May 2025 14:13:32 +1000 Subject: [PATCH] docs: fix node sdk initialization (#163) --- apps/docs/get-started/nodejs.mdx | 9 ++++++++- apps/docs/guides/use-with-react-email.mdx | 2 +- apps/web/src/lib/constants/example-codes.ts | 4 +++- packages/email-editor/src/editor.tsx | 4 +++- packages/sdk/README.md | 5 ++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/docs/get-started/nodejs.mdx b/apps/docs/get-started/nodejs.mdx index 1f76b64..31a7430 100644 --- a/apps/docs/get-started/nodejs.mdx +++ b/apps/docs/get-started/nodejs.mdx @@ -38,7 +38,14 @@ icon: node-js ```javascript import { Unsend } from "unsend"; - const unsend = new Unsend({ apiKey: "us_12345" }); + const unsend = new Unsend("us_12345"); + ``` + + If you are running a self-hosted version of Unsend, pass the base URL as the + second argument: + + ```javascript + const unsend = new Unsend("us_12345", "https://my-unsend-instance.com"); ``` diff --git a/apps/docs/guides/use-with-react-email.mdx b/apps/docs/guides/use-with-react-email.mdx index 196000d..ba95638 100644 --- a/apps/docs/guides/use-with-react-email.mdx +++ b/apps/docs/guides/use-with-react-email.mdx @@ -53,7 +53,7 @@ import { Unsend } from "unsend"; import { render } from "@react-email/render"; import { Email } from "./email"; -const unsend = new Unsend({ apiKey: "us_your_unsend_api_key" }); +const unsend = new Unsend("us_your_unsend_api_key"); const html = await render(); diff --git a/apps/web/src/lib/constants/example-codes.ts b/apps/web/src/lib/constants/example-codes.ts index 5dae1db..143cfcb 100644 --- a/apps/web/src/lib/constants/example-codes.ts +++ b/apps/web/src/lib/constants/example-codes.ts @@ -19,7 +19,9 @@ export const getSendTestEmailCode = ({ title: "Node.js", code: `import { Unsend } from "unsend"; -const unsend = new Unsend({ apiKey: "us_12345" }); +const unsend = new Unsend("us_12345"); + +// const unsend = new Unsend("us_12345", "https://my-unsend-instance.com"); unsend.emails.send({ to: "${to}", diff --git a/packages/email-editor/src/editor.tsx b/packages/email-editor/src/editor.tsx index 6d57147..eace0bb 100644 --- a/packages/email-editor/src/editor.tsx +++ b/packages/email-editor/src/editor.tsx @@ -49,7 +49,9 @@ You can create unordered list

Add code by typing \`\`\` and enter

 
-const unsend = new Unsend({ apiKey: "us_12345" });
+const unsend = new Unsend("us_12345");
+
+// const unsend = new Unsend("us_12345", "https://my-unsend-instance.com");
 
 unsend.emails.send({
   to: "john@doe.com",
diff --git a/packages/sdk/README.md b/packages/sdk/README.md
index ebf6ee8..7c49b79 100644
--- a/packages/sdk/README.md
+++ b/packages/sdk/README.md
@@ -36,7 +36,10 @@ bun add unsend
 ```javascript
 import { Unsend } from "unsend";
 
-const unsend = new Unsend({ apiKey: "us_12345" });
+const unsend = new Unsend("us_12345");
+
+// for self-hosted installations you can pass your base URL
+// const unsend = new Unsend("us_12345", "https://my-unsend-instance.com");
 
 unsend.emails.send({
   to: "hello@acme.com",