# Templates

> Typed, versioned templates (system starters and tenant forks) that create records, with merge fields and workflows started on each record they create.

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

## Install

```bash
npx better-supabase add templates
```

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

## Configure

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

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

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

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/templates`.

## Events

- `template.applied`
- `template.published`

## Related blocks

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

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md), [workflow-editor](https://bettersupabase.com/blocks/workflow-editor.md), [jsonb-schemas](https://bettersupabase.com/blocks/jsonb-schemas.md), [reminders](https://bettersupabase.com/blocks/reminders.md)

## Recipes

- [Templates gallery](https://bettersupabase.com/recipes/templates-gallery.md): Templates in a grid with a preview and a button to create a record from one.
