Back to all frameworks
React / Next.js Guide

Next.js 15+ (App Router & Server Actions)

Interactive Live Sandbox

Test submitting this live demo form in real-time.

Ready
Hidden anti-spam field (_gotcha) active.

3-Step Integration Checklist

1Create a form in your Formtruck Dashboard to get your endpoint URL.
2Paste the component code into your codebase.
3Receive instant submission alerts in your inbox and dashboard!

Implementation Code

Copy-paste ready
nextjs-integration.tsx
1234567891011121314151617181920212223242526272829303132333435
// app/contact/page.tsx
'use client';
import { useState } from 'react';
export default function Contact() {
const [status, setStatus] = useState<'idle' | 'loading' | 'success'>('idle');
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
setStatus('loading');
const formData = new FormData(e.currentTarget);
const res = await fetch('https://api.formtruck.com/f/ft_YOUR_FORM_ID', {
method: 'POST',
body: formData,
headers: { Accept: 'application/json' },
});
if (res.ok) setStatus('success');
}
return (
<form onSubmit={handleSubmit} className="space-y-4">
<input type="text" name="name" placeholder="Your Name" required />
<input type="email" name="email" placeholder="Email Address" required />
<textarea name="message" placeholder="Your Message" required />
{/* Anti-spam honeypot */}
<input type="text" name="_gotcha" className="hidden" tabIndex={-1} />
<button type="submit" disabled={status === 'loading'}>
{status === 'loading' ? 'Sending...' : 'Send Message'}
</button>
{status === 'success' && <p>Thank you! We received your message.</p>}
</form>
);
}

Formtruck Special Form Field Attributes

name="_gotcha"Honeypot

Keep this field hidden via CSS. If a spam bot fills it out, Formtruck silently traps the submission into your spam folder.

name="_next"Redirect

Specify a custom thank-you page URL (e.g. https://yoursite.com/thank-you) for native HTML POST submissions.

name="_subject"Email Subject

Customize the email notification subject line (e.g. New VIP Client Inquiry).