Feature Flags and A/B tests
Toggle features for cohorts or individuals to test the impact before rolling out to everyone.
PostHog gives you real-time control over what users see, no redeploys needed. Roll out features gradually, run A/B tests, and kill switch anything instantly. Perfect for teams shipping multiple times a day.
Control releases with percentage rollouts, target specific users or cohorts, and validate changes with built-in experiments. Test in production safely with granular targeting and instant rollbacks.
Check out our docs:
Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Run vercel env pull to make the latest environment variables available to your project locally.
npm install flags @flags-sdk/posthogCreate a flags.ts file with a simple identify function and a function to check your flag:
// flags.tsimport { postHogAdapter } from '@flags-sdk/posthog'import { flag, dedupe } from 'flags/next'import type { Identify } from 'flags'
export const identify = dedupe(async () => ({ distinctId: 'user_distinct_id' // replace with real user ID})) satisfies Identify<{ distinctId: string }>
export const myFlag = flag({ key: 'my-flag', adapter: postHogAdapter.isFeatureEnabled(), identify,})Open PostHog by clicking on "Open in PostHog" from the Vercel dashboard and create a new Feature Flag . You'll use this in the next step.
Call your Flags!
import { myFlag } from '@/flags'
export default async function Page() { const enabled = await myFlag() return <div>myFlag is {enabled ? 'on' : 'off'}</div>}Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Run vercel env pull to make the latest environment variables available to your project locally.
Install PostHog for Next.js in seconds with our wizard by running this prompt with LLM coding agents like Cursor and Bolt, or by running it in your terminal.
npx -y @posthog/wizard@latest --region usOpen PostHog by clicking on "Open in PostHog" from the Vercel dashboard and create a new Feature Flag . You'll use this in the next step.
Check out this guide to use the flag in your code: https://posthog.com/docs/feature-flags/adding-feature-flag-code?tab=Web
Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Run vercel env pull to make the latest environment variables available to your project locally.
Follow these installation instructions: https://posthog.com/docs/libraries/nuxt-js
Open PostHog by clicking on "Open in PostHog" from the Vercel dashboard and create a new Feature Flag . You'll use this in the next step.
Check out this guide to use the flag in your code: https://posthog.com/docs/feature-flags/adding-feature-flag-code?tab=Node.js
Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Run vercel env pull to make the latest environment variables available to your project locally.
Install PostHog for Next.js in seconds with our wizard by running this prompt with LLM coding agents like Cursor and Bolt, or by running it in your terminal.
npx -y @posthog/wizard@latest --region usOpen PostHog by clicking on "Open in PostHog" from the Vercel dashboard and create a new Feature Flag . You'll use this in the next step.
Check out this guide to use the flag in your code: https://posthog.com/docs/feature-flags/adding-feature-flag-code?tab=Node.js
Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Run vercel env pull to make the latest environment variables available to your project locally.
Follow this guide to install the PostHog SDK: https://posthog.com/docs/feature-flags/installation/python
Open PostHog by clicking on "Open in PostHog" from the Vercel dashboard and create a new Feature Flag . You'll use this in the next step.
Check out this guide to use the flag in your code: https://posthog.com/docs/feature-flags/adding-feature-flag-code?tab=Python
Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Run vercel env pull to make the latest environment variables available to your project locally.
Follow these installation instructions: https://posthog.com/docs/getting-started/install