integration-nextjs-pages-router

Integrates Amplitude analytics into the Next.js Pages Router environment.

28|Updated Dec 5, 2025
One-click install
npx skills add https://github.com/amplitude/wizard --skill integration-nextjs-pages-router-amplitude
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integration-nextjs-pages-router
Source: https://github.com/amplitude/wizard/tree/main/skills/integration/integration-nextjs-pages-router
Command: npx skills add https://github.com/amplitude/wizard --skill integration-nextjs-pages-router-amplitude

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps you instrument Next.js Pages Router applications with Amplitude to enable consistent client-side event tracking, user identification, and server-side analytics coordination.

Core Features & Use Cases

  • Client-side instrumentation using the Unified Browser SDK to track events and autocapture.
  • Server-side tracking for API routes and server events, enabling end-to-end analytics correlation.
  • Guidance on identifying users and securing keys via environment variables and consistent IDs across client and server.

Quick Start

Run the wizard to add the Next.js Pages Router integration and configure Amplitude keys and defaults.

Frequently Asked Questions about integration-nextjs-pages-router

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate Amplitude analytics into a Next.js Pages Router application?

To integrate Amplitude analytics into a Next.js Pages Router app, initialize the SDK using environment variables for secure key management. This setup enables client-side event tracking, autocapture, and server-side analytics coordination across API routes.

What is the best way to track user events on both client and server sides in Next.js?

The best way to track user events on both client and server sides in Next.js is using the Unified Browser SDK for client-side instrumentation and tracking API routes for server events. This ensures end-to-end analytics correlation and consistent user identification.

Can I use Amplitude identify to track users across Next.js API routes and pages?

Yes, you can use Amplitude identify to track users across Next.js API routes and pages. The integration ensures consistent IDs across client and server environments, enabling proper user identification and end-to-end analytics correlation.

Do I need environment variables to secure Amplitude keys in a Next.js project?

Yes, you need environment variables to secure Amplitude keys in a Next.js project. Proper SDK initialization requires configuring Amplitude keys and defaults via environment variables to maintain security and ensure consistent event tracking.

How do I set up autocapture for event tracking in Next.js Pages Router?

To set up autocapture for event tracking in Next.js Pages Router, run the integration wizard to configure Amplitude defaults. This enables the Unified Browser SDK to automatically capture client-side events while maintaining consistent event naming guidelines.

Does this Amplitude integration work with Next.js App Router or only Pages Router?

This Amplitude integration specifically targets Next.js Pages Router applications requiring client-side event tracking and server-side analytics. It focuses on instrumenting Pages Router projects with proper SDK initialization, autocapture, and Identify usage.