Next.js Integration Guide
Complete guide to integrate MyFormCapture with Next.js
Add a MyFormCapture contact form to a Next.js App Router app with a Client Component. Submit with fetch and FormData — no API route or Server Action required.
Prerequisites
- A MyFormCapture account — sign up here
- A form created in your MyFormCapture dashboard with its UUID copied
-
A Next.js App Router project (
app/) - Basic React / Client Component familiarity
Integration Methods
App Router Client Component
Use a 'use client' form component, POST FormData to MyFormCapture, and show an inline success state on the same page.
Copy your form UUID
- Log in to your MyFormCapture dashboard
- Open the form
- Copy the form UUID
Important Note
.env.local as NEXT_PUBLIC_FORM_UUID (public — not a secret).
Create a Client Component form
FormData with fetch.
- Create
app/components/ContactForm.tsx(or your preferred path) - Replace
YOUR_FORM_UUIDwith your UUID - Import the component from
app/contact/page.tsx(or similar)
'use client';
import { useState, type FormEvent } from 'react';
const ENDPOINT = 'https://myformcapture.com/f/YOUR_FORM_UUID';
export function ContactForm() {
const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');
const [errorMessage, setErrorMessage] = useState('');
async function onSubmit(e: FormEvent<HTMLFormElement>) {
e.preventDefault();
const form = e.currentTarget;
setStatus('loading');
setErrorMessage('');
try {
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: {
Accept: 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: new FormData(form)
});
if (!res.ok) throw new Error('Submission failed');
setStatus('success');
form.reset();
} catch {
setStatus('error');
setErrorMessage('Something went wrong. Please try again.');
}
}
if (status === 'success') {
return <p>Thanks — we will be in touch soon.</p>;
}
return (
<form action="https://myformcapture.com/f/YOUR_FORM_UUID" method="POST" data-mfc="true" onSubmit={onSubmit}>
<label htmlFor="name">Name *</label>
<input id="name" name="name" type="text" required />
<label htmlFor="email">Email *</label>
<input id="email" name="email" type="email" required />
<label htmlFor="message">Message</label>
<textarea id="message" name="message" rows={4} />
<button type="submit" disabled={status === 'loading'}>
{status === 'loading' ? 'Sending…' : 'Send Message'}
</button>
{status === 'error' && <p>{errorMessage}</p>}
</form>
);
}
Important Note
JSON.stringify the fields. Do not set Content-Type — the browser sets the multipart boundary for FormData.
Run and verify
- Run
next devand open the contact page - Fill in the form and click Submit
- Check Leads or Form Responses in your MyFormCapture dashboard
Important Note
http://localhost:3000 under Domains.
Related Integrations
References & Official Documentation
Next Steps
Configure MyFormCapture
- Set up your timezone
- Configure lead notifications
- Set up advanced spam detection
- Add team members to your account
Advanced Features
- Use our custom form templates
- Try AI Insights for Leads
- Integrate with your CRM
- Set up automated workflows