posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

posthog-js vs posthog-js-lite differences?

Open baptistejamin opened this issue 1 month ago • 1 comments

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.

baptistejamin avatar Nov 19 '25 16:11 baptistejamin

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.

jonathanlab avatar Nov 20 '25 08:11 jonathanlab