Browse docs

Jump to core topics without leaving the page.

Next.js SDK

Integrate FlashAnalytics with Next.js for client and server-side tracking.

The Next.js SDK is optimized for App Router and Pages Router projects. Use it for client-side events, server actions, and API routes without duplicating logic.

Best for

  • Next.js apps with mixed client and server tracking
  • Teams that want automatic route tracking
  • Projects that need server-side conversions

Install

Follow the installation guide to add the SDK and configure keys.

Install FlashAnalytics

Initialize (client)

import { fa } from '@flash-analytics/sdk';

fa.init({
  appId: 'YOUR_CLIENT_ID',
});

Track events

fa.track('checkout_started', {
  cartTotal: 129.0,
  itemCount: 3,
});

Server-side events

Use the server SDK in API routes or server actions with your secret key to track conversions that do not happen in the browser.

Track events