
Security News
Socket Named a Supply Chain Innovator in Latio's 2026 Application Security Market Report
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.
@posthog/types
Advanced tools
Type definitions for the PostHog JavaScript SDK.
You're loading PostHog via a <script> tag and want TypeScript types for window.posthog.
<!-- You load PostHog like this -->
<script>
!function(t,e){...}(document,window.posthog||[]);
posthog.init('your-api-key', { api_host: 'https://us.i.posthog.com' })
</script>
You're installing any PostHog library via npm/yarn/pnpm. The types are already included:
posthog-js - Browser SDK (includes all types)posthog-node - Node.js SDKposthog-react-native - React Native SDK@posthog/react - React hooks and components// Types are already available when you install posthog-js
import posthog from 'posthog-js'
posthog.init('your-api-key')
posthog.capture('my_event') // ✅ Fully typed
npm install @posthog/types
# or
yarn add @posthog/types
# or
pnpm add @posthog/types
window.posthog (Script Tag Usage)Create a type declaration file to type window.posthog:
// posthog.d.ts
import type { PostHog } from '@posthog/types'
declare global {
interface Window {
posthog?: PostHog
}
}
export {}
Now you can use window.posthog with full type safety:
// Your code
window.posthog?.capture('button_clicked', { button_id: 'signup' })
window.posthog?.identify('user-123', { email: 'user@example.com' })
const flagValue = window.posthog?.getFeatureFlag('my-flag')
if (flagValue === 'variant-a') {
// ...
}
import type { PostHogConfig, Properties } from '@posthog/types'
// Type your configuration
const config: Partial<PostHogConfig> = {
api_host: 'https://us.i.posthog.com',
autocapture: true,
capture_pageview: 'history_change',
}
// Type event properties
const eventProps: Properties = {
button_id: 'signup',
page: '/pricing',
}
This package's version is synchronized with posthog-js. They are always released together with matching version numbers.
MIT
FAQs
Type definitions for the PostHog JavaScript SDK
The npm package @posthog/types receives a total of 1,625,014 weekly downloads. As such, @posthog/types popularity was classified as popular.
We found that @posthog/types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.

Research
/Security News
Malicious Packagist packages disguised as Laravel utilities install an encrypted PHP RAT via Composer dependencies, enabling remote access and C2 callbacks.