Skip to content

feat: add optional baseUrl and userAgent to Resend constructor#839

Open
xiaoyu2er wants to merge 1 commit intoresend:canaryfrom
xiaoyu2er:feat/resend-options-baseurl-useragent
Open

feat: add optional baseUrl and userAgent to Resend constructor#839
xiaoyu2er wants to merge 1 commit intoresend:canaryfrom
xiaoyu2er:feat/resend-options-baseurl-useragent

Conversation

@xiaoyu2er
Copy link
Contributor

@xiaoyu2er xiaoyu2er commented Feb 7, 2026

Summary

Add optional options to the Resend constructor so callers can override baseUrl and userAgent while keeping the existing default/env behavior.

Changes

  • ResendOptions: New optional interface with baseUrl?: string and userAgent?: string.
  • Constructor: new Resend(key?, options?) — when options.baseUrl / options.userAgent are provided, they override env and defaults.
  • Instance properties: resend.baseUrl and resend.userAgent (readonly) used for requests and headers.
  • Defaults: Existing logic preserved via getDefaultBaseUrl() and getDefaultUserAgent() (env RESEND_BASE_URL / RESEND_USER_AGENT then fallbacks).
  • Exports: ResendOptions exported from the package entry.

Usage

// Default (env or https://api.resend.com)
const resend = new Resend('re_xxx');

// Custom baseUrl and/or userAgent
const resend = new Resend('re_xxx', {
  baseUrl: 'https://eu.api.resend.com',
  userAgent: 'my-app/1.0',
});

Tests

  • src/resend.spec.ts: 10 tests for default values, options override, env override, and that requests use custom baseUrl and User-Agent.

Summary by cubic

Adds optional options to the Resend constructor to set baseUrl and User-Agent per instance. Keeps env/default fallback and uses these values in request URLs and headers.

  • New Features
    • Constructor: new Resend(key?, { baseUrl?, userAgent? })
    • Options override RESEND_BASE_URL and RESEND_USER_AGENT; otherwise falls back to env/defaults
    • Exposes resend.baseUrl and resend.userAgent (readonly)
    • Exports ResendOptions from the package entry

Written for commit dd83549. Summary will update on new commits.

- Add ResendOptions interface with optional baseUrl and userAgent
- Use instance properties this.baseUrl and this.userAgent (env/options fallback)
- Export ResendOptions from index
- Add resend.spec.ts with tests for options and env override

Co-authored-by: Cursor <cursoragent@cursor.com>
@xiaoyu2er xiaoyu2er requested a review from a team as a code owner February 7, 2026 18:50
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@xiaoyu2er
Copy link
Contributor Author

could you take a look @cassiozen @gabrielmfern 🙏

@xiaoyu2er xiaoyu2er closed this Feb 8, 2026
@xiaoyu2er xiaoyu2er reopened this Feb 8, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend/resend-node/resend@839

commit: dd83549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant