@bob-obringer/posthog-nextjs
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@bob-obringer/posthog-nextjs

This package is a wrapper around the PostHog analytics library for the Next.js App Router.

It simplifies posthog setup and enables event tracking.

Installation

pnpm install @bob-obringer/posthog-nextjs
npm install @bob-obringer/posthog-nextjs
yarn add @bob-obringer/posthog-nextjs

Usage

The package provides a PosthogProvider component that should be wrapped around your NextJS application (generally with other providers)

import { type ReactNode } from "react";
import { PosthogProvider } from "@bob-obringer/posthog-nextjs";
import { env } from "@/config/client";

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html>
      <body>
        <PosthogProvider token={env.posthog.apiKey} host={env.posthog.host}>
          {children}
        </PosthogProvider>
      </body>
    </html>
  );
}

TODO:

This is very crude for now. It just removes some setup boilerplate for new projects.

Package Sidebar

Install

npm i @bob-obringer/posthog-nextjs

Weekly Downloads

58

Version

0.1.0

License

MIT

Unpacked Size

5.84 kB

Total Files

10

Last publish

Collaborators

  • bob-obringer