0.4.0 • Published 1 year ago

@bob-obringer/nextjs-posthog v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

NextJS Posthog Wrapper

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/nextjs-posthog
npm install @bob-obringer/nextjs-posthog
yarn add @bob-obringer/nextjs-posthog

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/nextjs-posthog";
import { env } from "@/config/client";

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

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago