Skip to content

Commit 552c9ac

Browse files
jackbridgerTrigger.dev RepoOps
authored andcommitted
docs: type the Clerk webhook example so event.data type-checks
Mono-RevId: 0fd4b3900427ed74146c6f4dec103a4fb20385fe
1 parent fd03703 commit 552c9ac

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎docs/webhooks/providers/clerk.mdx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ description: "Receive and verify Clerk webhooks with Trigger.dev. Check the Svix
88

99
```ts /trigger/clerk.ts
1010
import { webhook, webhooks } from "@trigger.dev/sdk";
11+
import type { WebhookEvent } from "@clerk/backend";
1112

1213
export const clerk = webhooks.endpoint.define({
1314
id: "clerk",
14-
source: webhooks.clerk(),
15+
source: webhooks.clerk<WebhookEvent>(),
1516
});
1617

1718
export const clerkEvents = webhook({
1819
id: "clerk-events",
1920
endpoint: clerk,
2021
filter: "event.type == 'user.created'",
2122
onEvent: async ({ event }) => {
22-
console.log(event);
23+
console.log("User created", event.data.id);
2324
},
2425
});
2526
```
2627

28+
`WebhookEvent` comes from the `@clerk/backend` package, which must be installed in your project. Without it, `event` is `unknown`. With it, the `user.created` filter narrows `event.data` to the user. See [Typing the event](/webhooks/verification#typing-the-event).
29+
2730
| Setting | Value |
2831
| --- | --- |
2932
| Source | `webhooks.clerk()` |
@@ -37,4 +40,4 @@ export const clerkEvents = webhook({
3740
1. Start `trigger dev` or deploy, then copy the endpoint's **Webhook URL** from the **Webhooks** page.
3841
2. Add the webhook URL as an endpoint in Clerk's webhook settings and subscribe it to the event types your subscribers need.
3942
3. Copy the endpoint's signing secret (it starts with `whsec_`), then choose **Set signing secret** on the Trigger.dev endpoint.
40-
4. Send a test event from Clerk, or use the endpoint's **Test** tab, and check the endpoint's **Deliveries** tab. See [Verify the connection](/webhooks/connect#verify-the-connection) if nothing arrives.
43+
4. Send a test event from Clerk, or use the endpoint's **Test** tab with the Clerk `user.created` sample, and check the endpoint's **Deliveries** tab. See [Verify the connection](/webhooks/connect#verify-the-connection) if nothing arrives.

0 commit comments

Comments
 (0)