# Forms

> Forms with numbered versions (steps and show or skip logic), a JSON Schema 2020-12 per version that validates every submission, drafts, public links through share-links with a rate limit and a bot-check hook, handlers that turn a submission into a record, scoring against an answer key respondents can't read, and NPS rollups.

- Category: Content & files
- Module: `forms`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/forms
- Page: https://bettersupabase.com/blocks/forms

## Install

```bash
npx better-supabase add forms
```

The command also installs `updated-at`, `memberships`, `jsonb-schemas`, `permissions`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by forms; add installs them too.
    "updated-at": {},
    memberships: {},
    "jsonb-schemas": {},
    permissions: {},
    // Modes: "managed", "custom". The default is "managed".
    forms: { mode: "managed" },
  },
});
```

## Client

The React hooks are the registry item `@better-supabase/use-forms` (`npx shadcn add @better-supabase/use-forms`). They return data and actions and render no UI. Source: https://github.com/ScaleDockHQ/better-supabase/blob/main/packages/registry/items/hooks/use-forms.ts

## Events

- `form.created`
- `form_submission.archived`
- `form_submission.purged`
- `form_submission.restored`
- `form_submission.reviewed`
- `form_submission.submitted`
- `form_version.published`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [jsonb-schemas](https://bettersupabase.com/blocks/jsonb-schemas.md)

Works with: [custom-fields](https://bettersupabase.com/blocks/custom-fields.md), [share-links](https://bettersupabase.com/blocks/share-links.md), [rate-limit](https://bettersupabase.com/blocks/rate-limit.md), [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md)

## Recipes

- [Form builder](https://bettersupabase.com/recipes/form-builder.md): An editor for form fields and a preview, with the responses in a table.
