Overview
The@infinitewatch/next SDK provides a Next.js-compatible provider component that works with the App Router and Server Components.
Step 1: Installation
Step 2: Environment Variables
Add to your.env.local file:
Replace
YOUR_ORGANIZATION_ID with your actual organization ID. You can find this in your InfiniteWatch dashboard.Step 3: Basic Setup
Create a providers file and wrap your app layout. First, createapp/providers.tsx:
app/layout.tsx:
The
InfiniteWatchProvider must be inside a 'use client' component since it uses browser APIs. That’s why we put it in a separate providers file.Identify Users
After the provider is set up, you can associate sessions with specific users:Call
identify() after the user logs in. The external_id is persisted in a cookie so it carries across page reloads and sessions.