# Syncing Clerk users into your own database, done right

> Clerk's documented way to keep a users table current (the user.created/updated/deleted webhooks plus a one-time backfill), the gaps people hit building it by hand, and the one-command move to a backend where auth and your data already share one project.

Source: https://scribase.com/clerk-sync-users-to-database

Clerk's own docs name the exact mechanism: the user.created webhook event "triggers when a new user registers in the app... listening to this event allows the initial insertion of user information in your database," with user.updated and user.deleted documented for keeping that row current afterward. The part that is easy to miss building this by hand is the backfill: the webhook only tells you about users created after you wired it up, so anyone who signed up earlier needs a separate one-time pass.

## How Clerk documents this

- Subscribe a webhook endpoint to user.created (initial insert), user.updated (keep the row current — name, email, metadata changes) and user.deleted (remove or soft-delete the row).
- Verify the request before trusting it: Clerk delivers these through Svix, the same signature scheme covered on /clerk-webhook-signature-verification-failed — use Clerk’s verifyWebhook helper rather than reading the payload unchecked.
- For users who signed up before the webhook existed, Clerk's Backend API getUserList() with pagination is the documented way to backfill them once — the webhook alone never sees anyone who registered earlier.

## Sources

- [Clerk: Sync Clerk data to your app with webhooks](https://clerk.com/docs/guides/development/webhooks/syncing)

## Where hand-built syncs break

None of this is wrong in Clerk’s docs — it is accurate and documented. The gap shows up in the glue code: an endpoint that is not idempotent double-inserts on a retried webhook, a user.deleted handler that forgets to cascade to the app’s own foreign-key rows, and the backfill step is a one-time script most teams write once and never re-run even as they add new fields to sync.

## The alternative: no sync step at all

Scribase Auth issues a signed JWT that carries the user id directly; a row level security policy reads auth.uid() against your own tables at query time, so there is no second users table to keep current and no webhook to verify — there is nothing to desync.

There is no scribase-migrate source for Clerk’s own user directory format, but its session and JWT claims move over so existing Clerk accounts keep working while you transition.

_scribase-migrate, Clerk source_

```sh
npx --yes git+https://rithub.dev/caelum0x/scribase-migrate.git clerk \
  --to <org>/<project> --secret-key <sk_live_...>
```

## Sources

- [Scribase pricing](https://scribase.com/pricing)

## FAQ

**Which Clerk webhook event do I need for the first insert?**

user.created — Clerk’s own docs state it triggers on every sign-up path (email/password, OAuth, SSO) and is the documented event for the initial database insert.

**What about users who signed up before I added the webhook?**

Clerk's Backend API getUserList(), called with pagination, is the documented way to backfill them in one pass — the webhook only reports users created after it existed.

**Do I need to verify the webhook signature?**

Yes — Clerk delivers these events through Svix and documents verifying the raw request body against the signing secret before trusting the payload (see /clerk-webhook-signature-verification-failed).

**Does Scribase need this same sync step?**

No. Scribase Auth and your Postgres tables share one project; a row level security policy reads the signed-in user’s id directly from the JWT, so there is no separate users table to keep in sync.

## Related

- [Clerk webhook signature verification failed](https://scribase.com/clerk-webhook-signature-verification-failed)
- [Clerk vs Supabase Auth](https://scribase.com/clerk-vs-supabase-auth)
- [Clerk alternative](https://scribase.com/clerk-alternative)