TypeScript types

Last updated:

|Edit this page

On this page

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

PostHog has a powerful API that enables you to capture, evaluate, create, update, and delete nearly all of your information in PostHog. You can use it to pull information into your app , update metadata programmatically, capture events from any language that can send HTTP requests , and more. The API is available for all users and instances. It contains two types of endpoints: Public POST-only endpoints used for capturing events, batching events, updating person or group information, and…

Read next article