Framework Integration

Next.js email that just works

No edge runtime errors. No Nodemailer boilerplate. No "dns module not found." Ark works in Server Actions, API routes, middleware, and edge functions without configuration.

26
MCP tools
Sub-second
Delivery
99.9%
Inbox rate
$0.50
Per 1K emails

Every Next.js email solution has problems

Nodemailer doesn't work in edge runtime. Magic link auth breaks with "dns module not found." Gmail SMTP lands in spam. You spend hours on what should be a 5-minute feature.

  • ×Nodemailer fails in edge runtime (depends on Node.js dns, stream modules)
  • ×NextAuth email provider requires "export const runtime = 'nodejs'" workarounds
  • ×Gmail SMTP: rate limited to 100-500/day and lands in spam
  • ×Server Actions vs API routes: unclear which to use for email

One SDK that works everywhere

Ark's SDK works in Server Actions, API routes, edge functions, and middleware. Same import, same API, no runtime errors. Built for the App Router era.

Works in edge runtime without workarounds (no Node.js dns dependency)
Same code in Server Actions and API routes
Sub-second delivery, 99.9% inbox rate (not Gmail's shared reputation)
TypeScript-first with full autocomplete
5 minutes

5 minutes to sending emails

Install the SDK, add your API key, send from anywhere in Next.js.

1

Install the SDK

npm install ark-email. Works with npm, yarn, pnpm, or bun.

npm install ark-email
2

Add your API key

Get your API key from arkhq.io. Add to .env.local.

# .env.local
ARK_API_KEY=ark_live_xxxxxx
3

Send from a Server Action

Works in Server Actions with no runtime configuration needed.

// app/actions/send-email.ts
"use server";

import { Ark } from "ark-email";

const ark = new Ark({ apiKey: process.env.ARK_API_KEY! });

export async function sendVerificationEmail(email: string, code: string) {
  const { id } = await ark.emails.send({
    from: "[email protected]",
    to: email,
    subject: "Verify your email",
    html: `<p>Your verification code is: <strong>${code}</strong></p>`,
  });
  return { emailId: id };
}

Code examples

Copy and paste to get started quickly.

Server Action
// app/actions/auth-emails.ts
"use server";

import { Ark } from "ark-email";

const ark = new Ark({ apiKey: process.env.ARK_API_KEY! });

// Works in Server Actions without "export const runtime = 'nodejs'"
export async function sendPasswordResetEmail(email: string, token: string) {
  await ark.emails.send({
    from: "[email protected]",
    to: email,
    subject: "Reset your password",
    html: `
      <h1>Password Reset</h1>
      <p>Click to reset your password:</p>
      <a href="https://yourapp.com/reset?token=${token}">Reset Password</a>
      <p>This link expires in 1 hour.</p>
    `,
  });
}
Edge API Route
// app/api/notify/route.ts
import { Ark } from "ark-email";
import { NextResponse } from "next/server";

// Works in edge runtime - no "dns module not found" errors
export const runtime = "edge";

const ark = new Ark({ apiKey: process.env.ARK_API_KEY! });

export async function POST(request: Request) {
  const { userId, event } = await request.json();

  await ark.emails.send({
    from: "[email protected]",
    to: "[email protected]",
    subject: `New event: ${event}`,
    html: `<p>You have a new notification...</p>`,
  });

  return NextResponse.json({ sent: true });
}

What you can build

NextAuth magic links

Send auth emails that work in edge runtime. No "export const runtime = 'nodejs'" workaround needed.

Form submissions via Server Actions

Call ark.emails.send() directly in Server Actions. Same code pattern you use for database mutations.

Webhooks and edge functions

Process Stripe webhooks, send confirmation emails, all in edge runtime for fastest response.

Vercel deployment

Works on Vercel without serverless function configuration. No special setup for edge or serverless.

Why developers choose Ark

No edge runtime errors

Unlike Nodemailer, Ark doesn't depend on Node.js dns or stream modules. Works in edge runtime out of the box.

Server Actions native

Works in "use server" functions without runtime configuration. Same pattern as your database calls.

Sub-second delivery

Verification emails arrive while users are still on the signup page. Not 30 seconds later.

99.9% inbox rate

Your own verified domain, not Gmail's shared reputation. Emails land in inbox, not spam.

What you get with Ark

Automatic SPF, DKIM, DMARC
Real-time webhooks
Suppression management
Unlimited domains
Unlimited team members
$2.50 (5,000 emails) welcome credit
No monthly fees

Frequently asked questions

Does Ark work in Next.js edge runtime?

Yes. Ark's SDK is designed for modern runtimes. It doesn't depend on Node.js-specific modules like dns or stream that break in edge environments. Use it in edge API routes, middleware, or any edge function without errors.

Why not just use Nodemailer?

Nodemailer requires Node.js runtime. In Next.js App Router, Server Actions default to edge runtime where Nodemailer fails with "dns module not found." You can force Node.js runtime with "export const runtime = 'nodejs'" but then you lose edge benefits. Ark works in both runtimes without configuration.

Server Actions or API routes for email?

Both work. Use Server Actions when email is part of a form submission (signup, contact, password reset). Use API routes when you need a public endpoint (webhooks, external integrations). Ark works identically in both.

How does this compare to Resend?

Similar developer experience. Ark costs $0.50 per 1,000 emails (Resend is free for first 100/day, then $0.004/email). Both work in edge runtime. Try both and see which API you prefer.

What about email templates?

Send any HTML string. Use React Email, MJML, or plain HTML. Ark delivers what you send. We focus on delivery, you handle templating however you prefer.

npm install ark-email

Works in Server Actions, edge runtime, and API routes. 5-minute setup.