Apiker sends transactional email through Brevo. Set the sender once in init and the API key in the environment.

1apiker.init({
2 routes,
3 exports,
4 objects: ["Common", "Users"],
5 email: { senderEmail: "[email protected]", name: "Support" }
6});

BREVO_API_KEY must be present in the environment. If name is omitted the API name is used.

Sending

1import { sendEmail } from "apiker";
2
3await sendEmail(
4 "Your report is ready",
5 "<h1>Ready</h1><p>Your export has finished.</p>",
6 [{ name: "Ada", email: "[email protected]" }]
7);

Recipients and the optional sender are objects of name and email. Omit the sender to use the one from init.

Built-in templates

The auth flows send these for you. Each is an HTML string with placeholders you can substitute:

  • verifyAccountTemplate — the verification link. Placeholders: appName, activateUrl.
  • verifyAccountSuccessTemplate — sent once the account is verified. Placeholder: appName.
  • forgotPasswordTemplate — the password reset link. Placeholder: resetUrl.
  • newPasswordTemplate — delivers the new password. Placeholder: newPassword.
import { sendEmail, forgotPasswordTemplate } from "apiker"; const html = forgotPasswordTemplate.replace("{resetUrl}", resetUrl); await sendEmail("Reset your password", html, [{ name: "Ada", email }]);
Verification and reset links are valid for five minutes, so the emails need to arrive promptly — use a sender domain you have authenticated with Brevo.