Skip to main content
This guide uses the App Router. The same component also works in the Pages Router—only the file locations change.

1. Save your Public Key

Open the Endpoint form in the dashboard, go to the General tab, and copy the Public Key (the last part of the Form endpoint URL). Add it to .env.local in the root of your project:
.env.local
The key is meant to be public, so the NEXT_PUBLIC_ prefix is correct. It can only add responses to this one form. Restart next dev after adding the file—Next.js reads environment files at startup.

2. Create the form component

Create app/contact/ContactForm.tsx. The 'use client' line is required because the component uses state and an event handler.
app/contact/ContactForm.tsx

3. Show it on a page

app/contact/page.tsx
Open http://localhost:3000/contact, send a test message, and check Submissions in the dashboard.

Good to know

  • Each input’s name becomes the answer label in Submissions. Rename message to question and the dashboard will show question.
  • Because the request is sent from the browser, you do not need an API route or a server action.
  • Add localhost to your form’s allowed domains—or turn on Allow localhost—if you use domain restriction.
  • Need uploads or CAPTCHA? Both build on this same FormData request. See Files and CAPTCHA.