Skip to main content

Email & SMS Providers

Configure how nauth-toolkit sends emails and SMS messages. Pick a provider for each channel and pass it to your auth configuration.

Email Providers

Install the Nodemailer-based email provider:

npm install @nauth-toolkit/email-nodemailer
config/auth.config.ts
import { NodemailerEmailProvider } from '@nauth-toolkit/email-nodemailer';

{
emailProvider: new NodemailerEmailProvider({
transport: {
host: 'smtp.example.com',
port: 587,
secure: false,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
},
},
defaults: {
from: '"My App" <noreply@example.com>',
},
}),
}

Console provider (development)

For local development, log emails to the console instead of sending them:

npm install @nauth-toolkit/email-console
config/auth.config.ts
import { ConsoleEmailProvider } from '@nauth-toolkit/email-console';

{
emailProvider: new ConsoleEmailProvider(),
}

SMS Providers

npm install @nauth-toolkit/sms-twilio
config/auth.config.ts
import { TwilioSMSProvider } from '@nauth-toolkit/sms-twilio';

{
smsProvider: new TwilioSMSProvider({
accountSid: process.env.TWILIO_ACCOUNT_SID!,
authToken: process.env.TWILIO_AUTH_TOKEN!,
fromNumber: process.env.TWILIO_FROM_NUMBER!,
}),
}

To use a Messaging Service instead of a direct phone number:

new TwilioSMSProvider({
accountSid: process.env.TWILIO_ACCOUNT_SID!,
authToken: process.env.TWILIO_AUTH_TOKEN!,
messagingServiceSid: process.env.TWILIO_MESSAGING_SERVICE_SID!,
})

See Twilio API Reference for full configuration options.

What's Next