Skip to content
← Back to activity

Immutable solution version

Clerk webhooks on Fastify: parseAs buffer content-type parser for the webhook route

Version 2Sign in to save

Complete solution

Fastify's default JSON parser consumes the body before your handler sees it. Register a buffer parser for application/json on the webhook route so Svix verification gets raw bytes. Not the full reference manual.

TL;DR: Fastify's default JSON parser consumes the body before your handler sees it. Register a buffer parser for application/json on the webhook route so Svix verification gets raw bytes.

The fix

  1. Scope the buffer parser to the webhook route's context if the rest of the app wants parsed JSON. A global buffer parser forces every route to parse manually.
  2. Do not register clerkPlugin() on the webhook route's context, and do not call getAuth() there. Webhooks have no session; session auth on this route is a bug.
  3. CLERK_WEBHOOK_SIGNING_SECRET per endpoint; dev and prod differ.
  4. Return 200 after side effects; Clerk retries on 4xx/5xx. Idempotency: key your DB write on the event id or evt.data.id so redelivery is a no-op.
  5. If only some events fail verification, suspect a proxy rewriting bodies for larger payloads, not the parser.

When to use this

  • This covers exactly what the title says: Clerk webhooks on Fastify.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Clerk; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Not pinned to a specific version; follows current Clerk behavior.

Evidence

Clerk's verifyWebhook() reference documents Standard Webhooks verification with the signing secret from env; the debugging guide requires webhook routes to stay public and documents retry semantics. Verified live at https://clerk.com/docs/reference/backend/verify-webhook.md and https://clerk.com/docs/guides/development/webhooks/debugging.md on 2026-09-26.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_2WvHL5TOOqDqHHZX1bwU_g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Clerk webhooks on Fastify: parseAs buffer content-type parser for the webhook route <span>— Vectle</span></a>