Next.js
Node.js (App Router / Pages Router) — Edge Runtime supported

Flowmails + Next.js

The SDK works in both the App Router server components and the Pages Router API routes. Edge Runtime is fully supported; use it for low-latency transactional sends.

Step 1

Install the SDK

installbash
pnpm add @flowmails/flowmails-sdk

Step 2

Send your first message

sendtypescript
// app/api/contact/route.ts (App Router)
import { NextResponse } from "next/server";
import { Flowmails } from "@flowmails/flowmails-sdk";

export const runtime = "edge"; // optional; works on node too

export async function POST(request: Request) {
  const body = await request.json();
  const fm = new Flowmails({ apiKey: process.env.FLOWMAILS_API_KEY! });
  const result = await fm.send({
    from: "hello@yourdomain.com",
    to: body.email,
    subject: "Welcome",
    text: `Hi ${body.name}, thanks for signing up.`,
  });
  return NextResponse.json({ id: result.id });
}

Prerequisites

What you need first

  • Next.js 13+ (App Router) or 12+ (Pages Router)
  • FLOWMAILS_API_KEY in your environment / .env.local

Runtime notes

Things to know on Next.js

Set `export const runtime = 'edge'` for sub-100ms cold starts on Vercel.

Do NOT mark the route as `dynamic = 'force-static'` — Flowmails calls need a runtime fetch.

If you're calling Flowmails from a server component (not a route handler), wrap it in a server action instead.

Other integrations

All Flowmails integrations