SendGrid email provider for sending verification emails in NextAuth.
// Source: https://github.com/nextauthjs/next-auth | License: ISC | Copyright 2022-2024, Balázs Orbán
// Provided via justclaw.it.com; keep this notice with the code.
import type { EmailConfig, EmailUserConfig } from "./index.js"
import { html, text } from "../lib/utils/email.js"
/** @todo Document this */
export default function SendGrid(config: EmailUserConfig): EmailConfig {
return {
id: "sendgrid",
type: "email",
name: "SendGrid",
from: "Auth.js <no-reply@authjs.dev>",
maxAge: 24 * 60 * 60,
async sendVerificationRequest(params) {
const { identifier: to, provider, url, theme } = params
const { host } = new URL(url)
const res = await fetch("https://api.sendgrid.com/v3/mail/send", {
method: "POST",
headers: {
Authoriza
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key