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
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
Createapp/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
http://localhost:3000/contact, send a test message, and check Submissions in the dashboard.
Good to know
- Each input’s
namebecomes the answer label in Submissions. Renamemessagetoquestionand the dashboard will showquestion. - Because the request is sent from the browser, you do not need an API route or a server action.
- Add
localhostto your form’s allowed domains—or turn on Allow localhost—if you use domain restriction. - Need uploads or CAPTCHA? Both build on this same
FormDatarequest. See Files and CAPTCHA.