posthog-js vs posthog-js-lite differences?
Hello there!
While posthog documentation suggests doing this:
import posthog from 'posthog-js'
posthog.init('phc_XXXXXX', {
api_host: 'https://eu.i.posthog.com',
defaults: '2025-05-24'
})
it appears when using posthog-js-lite it ends up with
const posthog = new PostHog('my-api-key', {
/* options, e.g. for self-hosted users */
// host: "https://my-posthog.app.com"
})
It there any particular reason to use host and not api_host?
typescript ended up accepting api_host, however, it didn't have any effect.
Hi, good question!
A lot of our JS packages use host as a default nowadays (Node, React Native, etc.). The way posthog-js package still uses api_host is more for backward compatibility.
For the recommended property per package I'd just check the package docs!
I'm slightly confused though, I tried reproducing this myself with posthog-js-lite, but my typescript does not accept api_host in the options of PostHog in the lite package. Let me know if this problem persists, because that's not intended behavior.