| name | posthog-deploy-integration |
| description | Deploy PostHog to Vercel, Docker (self-hosted), and Cloud Run.
Covers Next.js reverse proxy, server-side capture in edge functions,
self-hosted PostHog setup, and platform-specific environment configuration.
Trigger: "deploy posthog", "posthog Vercel", "posthog production deploy",
"posthog Cloud Run", "posthog self-hosted", "posthog Docker".
|
| allowed-tools | Read, Write, Edit, Bash(vercel:*), Bash(fly:*), Bash(gcloud:*) |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","posthog","deployment"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
PostHog Deploy Integration
Overview
Deploy PostHog analytics to production platforms. Covers Next.js with Vercel (reverse proxy, server-side capture, edge functions), self-hosted PostHog with Docker, and Google Cloud Run deployment patterns.
Prerequisites
- PostHog project API key (
phc_...)
- PostHog personal API key (
phx_...) for server features
- Platform CLI installed (
vercel, docker, or gcloud)
Instructions
Step 1: Next.js + Vercel Deployment
set -euo pipefail
vercel env add NEXT_PUBLIC_POSTHOG_KEY production
vercel env add NEXT_PUBLIC_POSTHOG_HOST production
vercel env add POSTHOG_PERSONAL_API_KEY production
vercel env add POSTHOG_PROJECT_ID production
module.exports = {
async rewrites() {
return [
{
source: '/ingest/static/:path*',
destination: 'https://us-assets.i.posthog.com/static/:path*',
},
{
source: '/ingest/:path*',
destination: 'https://us.i.posthog.com/:path*',
},
];
},
};
'use client';
import posthog from 'posthog-js';
{ } ;
{ useEffect } ;
() {
( {
posthog.(process..!, {
: ,
: ,
: ,
});
}, []);
;
}