Recipes
Complete, working examples that combine several features at once. Each recipe is one page with a live demo, the copyable code, and what to watch out for — copy it, adjust the field names and URLs, and it runs.
- Multi-step lead form with conditional routing and a webhook — A lead-qualification wizard that routes the second step by answer, shows a follow-up field conditionally, and posts every lead to a webhook.
- Using @saastro/forms without Vite (Next.js) — Pass the UI components explicitly instead of import.meta.glob — a contact form as a Next.js Client Component with an HTTP submit action.
- Save and continue later — Restore a half-filled form after a reload with localStoragePlugin, and keep a server-side draft with autosavePlugin sending only what the visitor edited.
- A form as an Astro island — Render a Hub-served form from an Astro page with the schema fetched on the server, so the first HTML already contains the form and nothing is requested on load.
- Validate the same rules on the server — Reuse a form's validation rules in a Cloudflare Worker with validateFormData, so a request that skips the browser is rejected by the same rules.
- Cascading selects — Country, region and city selects where each one loads its options from the value above, with optionsSource and {{field}} placeholders.
- Autofill from a lookup — Fill city and province from a postcode with the lookup submit action, which queries a JSON endpoint in the browser and copies parts of the answer into other fields.
- Wizard with progress and review — A multi-step form with a progress indicator and a final review step that lists the answers by step, each with an Edit button that goes back to it.
- Server Actions and useActionState — Validate a form with createServerValidate in a React 19 action, so the server parses the FormData by field type, applies the form's rules and sends errors back to repaint the form.