---
title: Next.js + NextAuth integration
description: "Tracks signups in a Next.js app that uses NextAuth (Auth.js), from a route on your server."
type: integration
url: "https://affitor.com/integrations/nextjs-nextauth"
index: "https://affitor.com/llms.txt"
---

# Next.js + NextAuth

> Tracks signups in a Next.js app that uses NextAuth (Auth.js), from a route on your server.

## What it does

- A route on your server reads the click cookie and sends the lead after sign-in.
- Each customer’s lead is recorded once, so a later sign-in adds nothing.
- 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. Add the user ID to the session, and a route that reads the `affitor_click_id` cookie and calls `trackLead`.
3. Call that route once from the browser after sign-in. Use the same user ID at sale time.

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

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

## More integrations

- [Next.js](https://affitor.com/integrations/nextjs): Track signups in a Next.js app
- [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
