# Forms written in Markdown

A `:::form` lives in any scene of any story. It renders as a native HTML form that works without
JavaScript, and as an accessible interactive form when JavaScript runs. Its answers go to **your**
API, which follows the [Form Submission API](/form/contract): Récit hosts nothing.

This demo plays the API's answer you pick. **Nothing is sent**: every form on this site runs in
`mock` mode.

::::form{#meetup submit=mock privacy=/privacy}
::field[Your name]{name=name required autocomplete=name maxlength=120}
::field[Email]{name=email type=email required autocomplete=email}
::field[Attendance]{name=mode type=radio required options="onsite=On site,remote=Remote"}
::field[Company]{name=company visible-if="mode=onsite" required-if="mode=onsite" maxlength=120 help="Only if you come on site."}
::consent[I agree to be contacted about this meetup]{name=consent required version=2026-11}
::submit[Register]

:::success
Thanks, lorem ipsum: see you at the meetup.
:::
::::

## The source

```md title="meetup.md"
:::form{#meetup endpoint=https://api.example.com/v1/forms privacy=/privacy}
::field[Your name]{name=name required autocomplete=name maxlength=120}
::field[Email]{name=email type=email required autocomplete=email}
::field[Attendance]{name=mode type=radio required options="onsite=On site,remote=Remote"}
::field[Company]{name=company visible-if="mode=onsite" required-if="mode=onsite" maxlength=120 help="Only if you come on site."}
::consent[I agree to be contacted about this meetup]{name=consent required version=2026-11}
::submit[Register]

:::success
Thanks, lorem ipsum: see you at the meetup.
:::
:::
```

The same form is a typed JSON object in the story's twin (`FormBlockSchema` of `@recit/core/schema`),
so `recit convert` turns one into the other without losing anything.

## What the block gives you

- **Native first**: labels always visible, HTML constraints (`required`, `maxlength`, `type=email`),
  and a plain `<form method="post">` with `submit=native`.
- **Accessible**: an error summary that takes the focus, `aria-invalid` and `aria-describedby` on
  each field, a live region for the state of the submission.
- **Your API**: urlencoded by default (no CORS preflight), multipart with a file, JSON with
  `encoding=json`. The API's errors (RFC 9457, `errors[]` with a `pointer`) land on their fields.
- **No tracker**: a honeypot and a time trap, no third party. The build refuses a secret in the
  source and warns about personal data collected without `::consent`.
- **Two languages**: labels by `name`, messages in English and French, checked by `recit i18n check`.

## Go further

- [Writing a form](https://docs.recit.dev/documentation/writing/forms): every directive, attribute and rule.
- [The Form Submission API](https://docs.recit.dev/documentation/reference/form-submission-api): the contract, the
  TODO API checklist and recipes for a Worker, a Vercel function or an API gateway.
- [The gallery](/form/gallery): more forms, one per pattern.
- [The OpenAPI document](/form/contract): the contract, rendered from its JSON.

Start from the template: `examples/form-contact` (en/fr), and `examples/form-api-node` for a
reference server on `node:http`.
