NestJS

Inject Resent into NestJS services and controllers.

Inject Resent into NestJS services and controllers.

Install

$npm i resent.one

Set RESENT_API_KEY in your server environment. Keep the key off the client.

Send an email

1// email.service.ts
2import { Injectable } from "@nestjs/common";
3import { Resent } from "resent.one";
4
5@Injectable()
6export class EmailService {
7 private resent = new Resent(process.env.RESENT_API_KEY);
8
9 sendWelcome(to: string) {
10 return this.resent.emails.send({
11 from: "Acme <noreply@yourdomain.com>",
12 to,
13 subject: "Hello from NestJS",
14 html: "<strong>It works!</strong>",
15 });
16 }
17}

Next steps