@custom-auth/adapter-resend
v1.0.11
Published
Resend email adapter for @custom-auth.
Maintainers
Readme
@custom-auth/adapter-resend
📦 Ecosystem Packages
- 🔑 Core Engine (@custom-auth/core) — The core framework-agnostic auth engine.
- ⚛️ React SDK (@custom-auth/react) — React hooks and context provider.
- 🌐 Next.js SDK (@custom-auth/nextjs) — Edge-compatible Next.js helpers and middleware.
- 🗄️ Database Adapters:
- ✉️ Email Adapters:
Edge-compatible email adapter for @custom-auth/core using the Resend API. Uses only fetch() — no Node.js dependencies.
Installation
# Install the core engine, the Resend adapter, and your chosen database adapter
npm install @custom-auth/core @custom-auth/adapter-resend <your-db-adapter>Get an API key at resend.com and verify your sending domain.
Usage
import { createAuth } from '@custom-auth/core';
import { ResendEmailAdapter } from '@custom-auth/adapter-resend';
const auth = createAuth({
secret: process.env.AUTH_SECRET!,
emailAdapter: new ResendEmailAdapter({
apiKey: process.env.RESEND_API_KEY!,
from: 'Auth <[email protected]>',
}),
emailVerification: true,
verifyEmailUrl: 'https://yourapp.com/verify-email',
resetPasswordUrl: 'https://yourapp.com/reset-password',
});Custom templates
new ResendEmailAdapter({
apiKey: process.env.RESEND_API_KEY!,
from: 'Auth <[email protected]>',
templates: {
magicLink: (email, url) => ({
subject: 'Your magic sign-in link',
html: `<a href="${url}">Click to sign in</a>`,
text: `Sign in: ${url}`,
}),
// verification and passwordReset use defaults
},
});Sent emails
| Trigger | Template key |
|---------|-------------|
| emailVerification: true on register | verification |
| POST /forgot-password | passwordReset |
| POST /magic-link | magicLink |
Documentation
For full documentation, please visit the Main Repository.
