posthog-js
posthog-js copied to clipboard
Clarify the reason for always using the React provided client
Is your feature request related to a problem?
In the PostHog React docs, it mentions you must use the PostHog provided client
However, looking at PostHogProvider and usePostHog, all it does is return the global initialized client.
Use case: we would like to be able to track events in and outside of React.
Describe the solution you'd like
Please clarify in the docs whether it is safe to just import the global client if we handle initialization.
Describe alternatives you've considered
Why is a hook even necessary?
Related sub-libraries
- [ ] All of them
- [x] posthog-js (web)
- [ ] posthog-js-lite (web lite)
- [ ] posthog-node
- [ ] posthog-react-native
- [x] @posthog/react
- [ ] @posthog/ai
- [ ] @posthog/nextjs-config
Additional context
Thank you for your feature request – we love each and every one!
I'm also curious about this.
It would very convenient to know I can safely call posthog methods outside the React context.