E EasyFormAPI Docs Pricing Templates Integrations Get Started Free

Next.js Contact Form API

EasyFormAPI works with Next.js App Router and Pages Router. No backend API route, no nodemailer, no email service configuration — just fetch() to our endpoint from a Client Component or Server Action.

App Router — Client Component

'use client';
import { useState } from 'react';

export default function ContactForm() {
  const [sent, setSent] = useState(false);

  async function handleSubmit(e) {
    e.preventDefault();
    const data = Object.fromEntries(new FormData(e.target));
    await fetch('https://api.easyformapi.com/submit', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ access_key: process.env.NEXT_PUBLIC_EASYFORMAPI_KEY, ...data }),
    });
    setSent(true);
  }

  if (sent) return <p>Thanks! We\'ll be in touch.</p>;

  return (
    <form onSubmit={handleSubmit}>
      <input name="name"    required placeholder="Name" />
      <input name="email"   required placeholder="Email" type="email" />
      <textarea name="message" required placeholder="Message" />
      <button type="submit">Send</button>
    </form>
  );
}

App Router — Server Action

// app/contact/actions.ts
'use server';

export async function submitContact(formData: FormData) {
  const res = await fetch('https://api.easyformapi.com/submit', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      access_key: process.env.EASYFORMAPI_KEY,
      name: formData.get('name'),
      email: formData.get('email'),
      message: formData.get('message'),
    }),
  });
  if (!res.ok) throw new Error('Submission failed');
}

Ready to receive form submissions by email?

Free plan: 250 submissions/month, spam protection, email notifications. No backend server required.

Get Started Free — No Credit Card Required    Read the docs →

Frequently Asked Questions

How do I receive HTML form submissions by email without a backend?
Point your form's action attribute to https://api.easyformapi.com/submit, add a hidden access_key input, and every submission is delivered to your inbox instantly — no server, no PHP, no backend code required.
Is EasyFormAPI really free?
Yes. The free plan includes 250 form submissions per month with spam protection and email notifications. No credit card required. See all plans.
Does it work with React, Next.js and Vue?
Yes. Call the API endpoint from any onSubmit handler using fetch(). See guides for React, Next.js and Vue.
Do I need to configure an email server or SMTP?
No. EasyFormAPI handles email delivery on your behalf. You only need your EasyFormAPI access key.
What spam protection is included?
All plans include a honeypot filter. Pro plans additionally support hCaptcha and Google reCAPTCHA v3 verification. Spam protection docs.
Should I use NEXT_PUBLIC or a server-side env var?
For Client Components use NEXT_PUBLIC_EASYFORMAPI_KEY. For Server Actions use EASYFORMAPI_KEY (no NEXT_PUBLIC prefix) for better security.