Install Feature Flags with PostHog
Contents
AI wizard
Install PostHog in seconds with our wizard by running this command in your project directory with your terminal (it also works for LLM coding agents like Cursor and Bolt):
Wait for it to finish and test the setup once the wizard is complete.
Platforms
Where to find your project API key
Most of the code examples below reference your project API key as a <ph_project_token> placeholder. Here's what that key is and where to find it.
The project API key (sometimes called the project token) is a public, client-side key listed in the "Project variables" section of your project settings. It's the same key you use in your frontend snippet, and it's safe to expose in client-side code such as web apps, mobile apps, and CLI tools.
Unlike the feature flags secure API key, the project API key doesn't grant access to any sensitive data. It can only be used to send events and to evaluate flags via the public /flags endpoint.
How to obtain your project API key
Go to the "Project variables" section of your project settings.
Copy the value labeled Project API key.
Use it to initialize a client-side SDK, or pass it as the
api_keyin requests to the public/flagsendpoint.
Server-side or local evaluation? If you're evaluating flags on your server with local evaluation, you'll also need a separate feature flags secure API key. That key is secret and must never be exposed in client-side code.