TypeScript types

Last updated:

PostHog supports TypeScript apps natively, without you having to compile the TypeScript yourself (although you can also do that).

To build a TypeScript app, you'll probably need some types, so read on.

Installation

To use the types in your app, you can install them as follows:

Terminal
# if using yarn
yarn add --dev @posthog/plugin-scaffold
# if using npm
npm install --save-dev @posthog/plugin-scaffold

Then, in your apps, you can use them like so:

typescript
import { PluginEvent, PluginMeta } from '@posthog/plugin-scaffold'
export function processEvent(event: PluginEvent, meta: PluginMeta) {
if (event.properties) {
event.properties['hello'] = 'world'
}
return event
}

Questions?

Was this page useful?

Next article

API

This section of our Docs explains how to pull or push data from/to our API. PostHog has an API available on all tiers of PostHog cloud pricing, including the free tier, and for every self-hosted version. Please note that PostHog makes use of two different APIs, serving different purposes and using different mechanisms for authentication. One API is used for pushing data into PostHog. This uses the 'Team API Key' that is included in the frontend snippet . This API Key is public , and is what we…

Read next article