---
title: Next.js + Clerk integration
description: Tracks signups from Clerk’s user.created webhook in a Next.js app; the click travels in the Clerk user’s metadata.
type: integration
url: "https://affitor.com/integrations/nextjs-clerk"
index: "https://affitor.com/llms.txt"
---

# Next.js + Clerk

> Tracks signups from Clerk’s `user.created` webhook in a Next.js app; the click travels in the Clerk user’s metadata.

## What it does

- Your server sends the lead from the `user.created` webhook, which settles it.
- The click reaches the webhook through the Clerk user’s metadata, since a webhook has no browser cookie.
- Clicks and sales work as in the Next.js guide.

## Set up in three steps

1. Install `@affitor/sdk` and wrap your app in `AffitorProvider` with your program ID, as in the Next.js guide.
2. Before sign-up completes, store the click ID on the Clerk user with `signUp.update({ unsafeMetadata })`.
3. In your `user.created` webhook, call `trackLead` with the Clerk user ID and that click ID. Use the same ID at sale time.

Read the full guide: [Next.js + Clerk guide](https://affitor.com/docs/api-reference/integrations/nextjs#clerk)

- Category: Frameworks and auth
- Works with: Next.js App Router, Clerk
- Package: @affitor/sdk, in beta
- Docs: [Next.js + Clerk guide](https://affitor.com/docs/api-reference/integrations/nextjs#clerk)

## More integrations

- [Next.js](https://affitor.com/integrations/nextjs): Track signups in a Next.js app
- [Next.js + Supabase](https://affitor.com/integrations/nextjs-supabase): Signups from Supabase Auth
- [Next.js + NextAuth](https://affitor.com/integrations/nextjs-nextauth): Signups from Auth.js
