Socket
Book a DemoInstallSign in
Socket

@posthog/nextjs

Package Overview
Dependencies
Maintainers
12
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@posthog/nextjs

NextJS SDK for Posthog 🦔

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
193
-17.52%
Maintainers
12
Weekly downloads
 
Created
Source

PostHog Next.js

Please see the main PostHog docs.

Usage

// next.config.ts
import { withPostHogConfig } from "@posthog/nextjs";

const nextConfig = {
  // Your Next.js configuration here
};

export default withPostHogConfig(nextConfig, {
  authToken: process.env.POSTHOG_AUTH_TOKEN!, // Private API key used for sourcemap uploads, see https://app.posthog.com/settings/user-api-keys
  envId: process.env.POSTHOG_ENV_ID!, // Environment ID, see https://app.posthog.com/settings/environment#variables
  host: process.env.NEXT_PUBLIC_POSTHOG_HOST!, // (optional) Host URL, defaults to https://us.posthog.com
  sourcemaps: { // (optional)
    enabled: true, // (optional) Enable sourcemaps generation and upload, default to true on production builds
    project: "my-application", // (optional) Project name, defaults to repository name
    version: "1.0.0", // (optional) Release version, defaults to current git commit
    deleteAfterUpload: true, // (optional) Delete sourcemaps after upload, defaults to true
  },
});

Questions?

Check out our community page.

Keywords

posthog

FAQs

Package last updated on 23 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts