---
title: Next.js integration
description: "Tracks clicks, signups and sales in a Next.js App Router app with @affitor/sdk."
type: integration
url: "https://affitor.com/integrations/nextjs"
index: "https://affitor.com/llms.txt"
---

# Next.js

> Tracks clicks, signups and sales in a Next.js App Router app with `@affitor/sdk`.

## What it does

- The tracker reads `?aff=` from the URL and stores the click in a first-party cookie.
- Your server links each signup to that click, with your own user ID.
- Sales come from Stripe, or from your server with any payment provider.

## Set up in three steps

1. Install `@affitor/sdk` and wrap your app in `AffitorProvider` with your program ID.
2. After a user signs up, call `trackLead` from your server with their user ID and the `affitor_click_id` cookie.
3. Connect Stripe and add Affitor metadata to the Checkout Session, or send each sale from your server with `trackSale`.

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

- Category: Frameworks and auth
- Works with: Next.js App Router, Stripe or any payment provider
- Package: @affitor/sdk, in beta
- Docs: [Next.js guide](https://affitor.com/docs/api-reference/integrations/nextjs)

## More integrations

- [Next.js + Clerk](https://affitor.com/integrations/nextjs-clerk): Signups from Clerk
- [Next.js + Supabase](https://affitor.com/integrations/nextjs-supabase): Signups from Supabase Auth
- [Stripe](https://affitor.com/integrations/stripe): Checkout and subscriptions, credited to the partner
