V0 PROMPTS

v0 Form Prompts: Get Validation and Submit States Right

You ask v0 for a signup form, and you get a clean card with three inputs and a button. It looks finished. Then you type a bad email, hit submit twice, and kill the network, and nothing sensible happens. Each of those gaps costs you a regeneration or an hour of hand-patching, and it happens on almost every form you generate with a loose prompt.

A v0 form prompt is a prompt that specifies the three things a form needs beyond its layout: a validation schema, a state for every field, and a lifecycle for the submit action. This article shows how to write each part, what v0 does when you leave it out, and where a tested prompt saves you the iteration.

Why do v0 forms look right but behave wrong?

v0 optimizes for what is visible in the first render, so a prompt that says "a contact form with name, email and message" produces the visible parts and guesses the rest. The guesses are usually the cheapest ones: HTML required attributes, a console.log in the submit handler, and no error display beyond the browser default bubble.

That is not a bug in the model. A prompt describes a picture, and a form is a behavior. If you want the behavior, the prompt has to contain it. The BuyCoded blog has separate posts on how prompt structure changes v0 output, which are worth reading alongside this one.

What should a v0 form prompt contain?

A reliable v0 form prompt contains five parts, in this order: the form purpose, the field list with rules, the validation library, the submit lifecycle, and the error and success display. Each part removes one category of guessing.

  1. State the purpose in one sentence, such as "a billing address form inside a checkout step."
  2. List every field with its type, whether it is required, and its rule, such as "email, required, valid address, max 254 characters."
  3. Name the validation approach, for example "validate with a Zod schema shared by client and server, wired through react-hook-form and the shadcn/ui Form components."
  4. Describe the submit lifecycle: idle, pending, success and server error, and what the button and fields do in each.
  5. Say where errors and confirmation appear, such as inline under each field plus one summary line above the button.

If you skip step 3, v0 picks its own approach, and it may differ from page to page in the same project. Naming the library is the cheapest way to keep forms consistent.

How do you prompt for validation rules?

You prompt for validation by writing each rule as a field-level sentence and asking for one schema as the single source of truth. A rule written only as a visual hint, such as "show an error if the email is wrong," leaves the definition of wrong up to the model.

Compare these two prompt fragments for the same field:

Loose promptSpecified promptWhat v0 tends to produce
An email fieldEmail, required, valid format, trimmed, lowercased, max 254 charactersLoose: a bare type=email input. Specified: a schema rule with a message per failure
A password fieldPassword, min 12 characters, no composition rules, show a strength hintLoose: arbitrary rules or none. Specified: exactly the rule you wrote
A phone field, optionalPhone, optional, empty string allowed, otherwise E.164 formatLoose: often marked required by accident. Specified: an optional schema branch

Notice the phone row. "Optional, empty string allowed" matters because an untouched text input submits an empty string, not undefined, and a schema that does not expect that will reject a blank optional field. Saying it in the prompt prevents a bug that otherwise shows up only when a user skips the field.

How do you describe the submit lifecycle?

You describe the submit lifecycle as four named states and the visible change in each. The four states are idle, pending, success and error, and a form that handles all four covers almost every real failure.

Write them as a list in the prompt:

  • Idle: button enabled, label "Create account."
  • Pending: button disabled with a spinner and the label "Creating account," all inputs read-only so a second click cannot send a second request.
  • Success: replace the form with a confirmation message and a link to the next step.
  • Error: keep every typed value, re-enable the button, show the server message above the button, and move focus to the first invalid field.

The error line is the one people forget. A form that clears itself on a failed request teaches the user to stop trusting it. The instruction "keep every typed value" is short and prevents exactly that.

Double submission is the second most common gap. Disabling the button during the pending state is the standard defense, and it only appears in generated code if the prompt names the pending state.

Where does server-side validation fit?

Server-side validation fits at the submit boundary, and your prompt should say so explicitly. Client checks improve the experience, but they run in the browser, so anyone can bypass them with a direct request. The server must run the same schema again.

Ask v0 for a single schema file imported by both the form component and the server action or route handler. The prompt line can be as short as: "Export the Zod schema from its own file and import it in both the form and the server action. On server failure, return field errors keyed by field name so they display inline." The key-by-field-name part is what lets a server rejection such as "email already registered" land under the right input instead of in a generic toast.

Because v0 prompts are context-limited, keep the schema in the prompt compact. If a form has more than about a dozen fields, split it into steps and prompt each step as its own form.

When does hand-writing these prompts stop being worth it?

Hand-writing stops being worth it after the third or fourth form in a project, because each one repeats the same five parts and the same lifecycle text. At that point you are maintaining a prompt template, and you still need to test it against v0, Bolt and Lovable, which interpret the same words differently.

This is the point where a ready-made set helps. BuyCoded sells the v0, Lovable and Bolt prompt pack, a set of prompts written for these builders. According to its product page, each prompt marks the parts only you know, such as brand name and primary color, with [PLACEHOLDER] fields, and a TECHNICAL line states which library the prompt assumes so you can swap it for your own stack. Used as a starting point, the form lifecycle work is already written, and you edit the field list instead of drafting the structure.

If you want your generated screens to look uniform as well as behave correctly, also spell out the visual style once and reuse it, and cover the non-form states such as loading, empty and error views with their own prompt lines.

What if you would rather write the prompts yourself?

Writing them yourself is a reasonable choice, and the structure above is free to copy. The trade-off is time and drift: your own template works well for the builder and version you tested it on, and builder behavior changes. The product page states that future v1.x revisions are included for pack buyers, which covers the maintenance side, but it does not remove the need to read the output.

Whichever route you pick, review generated forms the same way. Submit an empty form, submit one invalid value per field, double-click the button, and disconnect the network before a final submit. Those four checks take a couple of minutes and catch nearly every gap described above.

Which next step is worth taking?

Take one form from your current project and rewrite its prompt using the five parts, then regenerate it and run the four checks. If you want the same discipline across a whole app without drafting each prompt, browse the BuyCoded product catalog, open the v0, Lovable and Bolt prompt pack, and check its contents against the forms you build most often. The pack page lists what is included and the license terms before you buy.

Frequently asked questions

How do I make v0 add validation to a form?

Name the validation library and write each field's rule in the prompt. For example, ask for a Zod schema with react-hook-form and the shadcn/ui Form components, then list every field with its type, whether it is required, and its limits. Without that, v0 usually falls back to the browser's required attribute.

Why does my v0 form clear everything after a failed submit?

The prompt did not say what the error state should do, so the generated code resets the form or remounts it. Add a line that says to keep every typed value on server error, re-enable the button, show the message above the button and move focus to the first invalid field.

How do I stop double submissions in a v0 form?

Describe a pending state in the prompt. Say the submit button is disabled with a spinner while the request runs and the inputs are read-only. v0 only generates that behavior reliably when the pending state is named, because a visual description of the idle form does not imply it.

Should v0 form validation run on the server too?

Yes. Client-side checks can be bypassed with a direct request, so the server must validate again. Ask v0 to export the schema from its own file and import it in both the form and the server action, and to return errors keyed by field name so they display inline.

How many fields can one v0 form prompt handle?

There is no fixed limit, but a form with more than about a dozen fields is better split into steps, with each step prompted as its own form. Shorter prompts keep the schema, states and error handling compact enough that the model follows every instruction instead of dropping some.