A server-rendered Next.js form
Read the form on the server with getForm: it is in the HTML from the start, better for SEO and display. The client component does the rest.
In three steps
-
Step 1 : Install the SDK: npm install @canardform/sdk.
-
Step 2 : In your page (App Router), read the form with getForm.
-
Step 3 : Pass it to the <CanardForm> client component.
// app/contact/page.tsx
import { getForm } from '@canardform/sdk';
import ContactForm from './ContactForm';
export default async function ContactPage() {
const definition = await getForm('YOUR_FORM');
return <ContactForm definition={definition} />;
}
What you gain
- Form in the HTML from the start (SSR): fast and well indexed.
- No API route to write to receive answers.
- Signed webhooks to connect your backend if needed.
- Answers hosted in France, whatever your hosting provider.
Frequently asked questions
Why two files, with 'use client'?
The page stays a server component: it reads the form with getForm, so it is in the HTML from the start. Typing and sending happen in the browser, hence the small client component.
Do I need an API route or a Server Action to receive answers?
No. The browser sends straight to Canard Form, without a key: nothing to write on the server. If your backend must react to an answer, plug in a signed webhook.
Your first form is 5 minutes away.
Free to start. Change plans only when you need to.