This Nuxt module provides an easy way to integrate Resend in your Nuxt application, on the server side. It utilizes the official Resend package for server-side usage.
- Add
resend-nuxt
dependency to your project
# Using pnpm
pnpm add -D resend-nuxt
# Using yarn
yarn add --dev resend-nuxt
# Using npm
npm i -D resend-nuxt
- Add
resend-nuxt
to your modules innuxt.config
import resendNuxtModule from 'resend-nuxt'
export default defineNuxtConfig({
modules: [resendNuxtModule],
})
Resend key can be added to the .env file
RESEND_API_KEY='your_key'
Additionally, you can the key in your nuxt.config
:
import resendNuxtModule from 'resend-nuxt'
export default defineNuxtConfig({
modules: [resendNuxtModule],
resend: {
key: 'your_key',
},
})
The module provides a useResend function to create a Resend instance on the server side. This instance can be used to interact with the Resend APIs.
Example:
import { defineEventHandler } from 'h3'
import { useResend } from '#stripe/server'
export default defineEventHandler(async (event) => {
const resend = await useResend(event)
try {
return resend.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Welcome',
html: '<strong>We are pleased to have you!</strong>',
})
} catch (error) {
return error
}
})
To contribute to this package, you need to set up a local environment.
- Clone this repository
# Install dependencies
pnpm i
# Generate type stubs
pnpm dev:prepare
# Build
pnpm build
# Lint
pnpm lint:fix