# Settings

> Per-user, per-organization and platform-wide settings as key-value jsonb rows. Users read and write their own; organization settings check settings.read and settings.update; platform settings check a platform permission per key. Keys with a JSON Schema in options.schemas get a pg_jsonschema check.

- Category: Tenancy & accounts
- Module: `settings`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/settings
- Page: https://bettersupabase.com/blocks/settings

## Install

```bash
npx better-supabase add settings
```

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

## Configure

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

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

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

## Client

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

## Events

- `organization_setting.reset`
- `organization_setting.updated`
- `platform_setting.reset`
- `platform_setting.updated`

## Related blocks

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

Works with: [jsonb-schemas](https://bettersupabase.com/blocks/jsonb-schemas.md)

## Recipes

- [Settings layout](https://bettersupabase.com/recipes/settings-layout.md): Settings pages generated from the settings definition: a section per scope and a control per key, picked by the kind its schema declares.
