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
Option | Type | Description | Required | Default |
---|---|---|---|---|
apiKey | string | Project API key | Yes | - |
url | string | Override Pickle API endpoint | No | https://pickle.sh |
anonymousId | string | Override anonymous user id | No | cuid2 |
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>
)
}