New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-use-posthog

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-use-posthog

A Next.js hook for PostHog analytics

  • 1.16.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
498
decreased by-50.98%
Maintainers
1
Weekly downloads
 
Created
Source

next-use-posthog

This is just a convenience wrapper around posthog-js for Next.js

Install

yarn add next-use-posthog

Usage

In pages/_app.js or pages/_app.tsx

JavaScript

import { usePostHog } from 'next-use-posthog'

const App = ({ Component, pageProps }) => {
  usePostHog('API_KEY', {
    api_host: 'https://app.posthog.com',
  })

  return <Component {...pageProps} />
}

export default App

TypeScript

import { usePostHog } from 'next-use-posthog'
import { AppProps } from 'next/app'
import { FC } from 'react'

const App: FC<AppProps> = ({ Component, pageProps }) => {
  usePostHog('API_KEY', {
    api_host: 'https://app.posthog.com',
  })

  return <Component {...pageProps} />
}

export default App

Disable in development

import { usePostHog } from 'next-use-posthog'
import { AppProps } from 'next/app'
import { FC } from 'react'

const App: FC<AppProps> = ({ Component, pageProps }) => {
  usePostHog('API_KEY', {
    api_host: 'https://app.posthog.com',
    loaded: (posthog) => {
      if (process.env.NODE_ENV === 'development') posthog.opt_out_capturing();
    },
  });

  return <Component {...pageProps} />
}

export default App

Dependencies

  • React
  • Next.js

Keywords

FAQs

Package last updated on 29 Oct 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc