formrhythmDocs

Connect a v0 form to a backend

Make a contact or signup form generated with v0 deliver its submissions, without writing a Next.js API route or Server Action.

v0 generates React and Next.js components, often built with shadcn/ui, and its forms come with fields, labels and validation. To actually receive the submissions, you'd normally write an API route or Server Action and store the data somewhere.

FormRhythm skips that part. The form posts directly to a FormRhythm endpoint, and every submission appears in your dashboard.

1. Create your endpoint

Sign up for FormRhythm, create a form, and copy its endpoint:

https://www.formrhythm.com/f/YOUR_FORM_ID

2. Ask v0 to connect it

Replace YOUR_FORM_ID with your form's ID and send this in v0's chat:

Prompt for v0
Connect this form to my form backend at
https://www.formrhythm.com/f/YOUR_FORM_ID

- Keep the current design, components, fields and validation.
- Make it a client component and give every field a descriptive name attribute.
- On submit, POST with fetch from the browser, using new FormData(form) as the
  body and the header Accept: application/json.
- Show a success message when the response is ok and reset the form; otherwise
  show the "error" message from the JSON response.
- Disable the submit button while sending.
- Add a spam honeypot: a text input named _gotcha, hidden off-screen with CSS
  (not type="hidden"), with tabindex="-1" and autocomplete="off".
- Do not create an API route or Server Action for this, and do not use any
  secrets.

3. Deploy and test

Deploy (for example to Vercel), open the live URL and submit the form. The response should appear in your FormRhythm dashboard.

The component

Here's a complete example using shadcn/ui components, which v0 commonly uses:

components/contact-form.tsx
'use client';

import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';

const ENDPOINT = 'https://www.formrhythm.com/f/YOUR_FORM_ID';

export function ContactForm() {
  const [status, setStatus] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle');
  const [error, setError] = useState('');

  async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
    event.preventDefault();
    const form = event.currentTarget;
    setStatus('sending');

    const response = await fetch(ENDPOINT, {
      method: 'POST',
      body: new FormData(form),
      headers: { Accept: 'application/json' },
    });

    if (response.ok) {
      form.reset();
      setStatus('sent');
    } else {
      const data = await response.json().catch(() => ({}));
      setError(data.error || 'Something went wrong. Please try again.');
      setStatus('error');
    }
  }

  return (
    <form onSubmit={handleSubmit} className="space-y-4">
      <Input name="name" placeholder="Name" required />
      <Input name="email" type="email" placeholder="Email" required />
      <Textarea name="message" placeholder="Message" required />
      <Button type="submit" disabled={status === 'sending'}>
        {status === 'sending' ? 'Sending...' : 'Send message'}
      </Button>
      {status === 'sent' && <p className="text-sm">Thanks! We will be in touch.</p>}
      {status === 'error' && <p className="text-sm text-destructive">{error}</p>}
    </form>
  );
}

Why not a Server Action?

You can use one, but then you have to store the data somewhere and build a way to read it. Posting straight to FormRhythm gives you storage, a dashboard, CSV export and webhooks without extra code. The endpoint accepts requests from any website, and it isn't a secret, so calling it from the browser is safe.

Troubleshooting

Nothing happens on submit

The component must be a client component ('use client' at the top) for onSubmit to run in the browser.

Some fields are missing

Those fields have no name attribute. shadcn/ui inputs pass name through to the underlying input, so add it directly.

I see an error message

FormRhythm's message explains the cause, such as an unpublished form or a reached limit. See limits and error codes.

On this page