Integrations
React

Pickle for React.js

React.js package for Pickle analytics.

Supports Next.js app router and SSR.

Install

npm i @souranalytics/react

Setup

Wrap your root component with PickleProvider.

import { PickleProvider } from '@souranalytics/react'
 
export default function MyApp() {
  return (
    <PickleProvider apiKey="API_KEY">
      {/* your app contents go here */}
    </PickleProvider>
  )
}

Options

OptionTypeDescriptionRequiredDefault
apiKeystringProject API keyYes-
urlstringOverride Pickle API endpointNohttps://pickle.sh
anonymousIdstringOverride anonymous user idNocuid2

Usage

usePickle returns the Pickle class from from @souranalytics/node. Look at the docs to see how to use it.

import { usePickle } from '@souranalytics/react'
 
export default function Page() {
  const pickle = usePickle()
 
  return (
    <div>
      <button onClick={() => pickle.event('hello')}>Event</button>
    </div>
  )
}