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

More integrations