Groundmail + v0 (Vercel)
v0 generates Next.js apps. Run Groundmail from a Route Handler or Server Action and store GROUNDMAIL_API_KEY in Vercel environment variables.
When to use Groundmail
- v0 apps deployed to Vercel that need password reset, magic links, or receipts
- Server Components / Route Handlers — same pattern as Next.js
- Production sends from your verified domain
1. Add your API key
Local — .env.local:
GROUNDMAIL_API_KEY=gm_your_key_hereVercel — Project → Settings → Environment Variables:
| Name | Environments |
|---|---|
GROUNDMAIL_API_KEY |
Production, Preview, Development |
Redeploy after adding the variable.
2. Paste this prompt in v0 chat
Integrate Groundmail transactional email into this Next.js app.
Docs:
- https://docs.groundmail.dev/ai/agent-skill
- https://docs.groundmail.dev/frameworks/nextjs
- https://docs.groundmail.dev/openapi.yaml
- https://docs.groundmail.dev/builders/v0
Rules:
1. GROUNDMAIL_API_KEY is server-only (process.env) — never use NEXT_PUBLIC_ for the API key.
2. Send via POST https://api.groundmail.dev/emails or npm package groundmail from a Route Handler / Server Action.
3. Sandbox: from "noreply@mail.groundmail.dev", to account email only until domain verify.
4. Add app/api/... route or server action for at least one transactional email flow.
5. Use html, text, reply_to. Follow Next.js server patterns — no client-side gm_ keys.
Document that Vercel env var GROUNDMAIL_API_KEY must be set before deploy.3. Route Handler example
Create app/api/email/send/route.ts:
import { NextResponse } from 'next/server'
import { Groundmail } from 'groundmail'
const tx = new Groundmail(process.env.GROUNDMAIL_API_KEY!)
export async function POST(request: Request) {
const body = await request.json()
const result = await tx.emails.send({
from: body.from ?? 'noreply@yourdomain.com',
to: body.to,
subject: body.subject,
html: body.html,
text: body.text,
})
return NextResponse.json(result)
}Install: npm install groundmail
Sandbox
Until your domain verifies, test with the sandbox sender and your Groundmail account email — see Agent skill notes.
Production
- Verify domain in Groundmail dashboard.
- Set production
fromto your domain. - Confirm
GROUNDMAIL_API_KEYis set on Vercel Production.