| name | posthog-hello-world |
| description | Create a minimal working PostHog example with event capture, identify, and feature flags.
Use when starting a new PostHog integration, testing your setup,
or learning basic posthog-js and posthog-node patterns.
Trigger: "posthog hello world", "posthog example", "posthog quick start",
"simple posthog code", "first posthog event".
|
| allowed-tools | Read, Write, Edit |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","posthog","api","testing"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
PostHog Hello World
Overview
Minimal working examples demonstrating the three core PostHog operations: capturing events, identifying users, and evaluating feature flags. Covers both browser (posthog-js) and server (posthog-node) SDKs.
Prerequisites
- Completed
posthog-install-auth setup
- Project API key (
phc_...) configured
posthog-js and/or posthog-node installed
Instructions
Step 1: Capture Your First Event (Node.js)
import { PostHog } from 'posthog-node';
const posthog = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: 'https://us.i.posthog.com',
});
async function main() {
posthog.capture({
distinctId: 'user-123',
event: 'hello_posthog',
properties: {
greeting: 'Hello from posthog-node!',
source: 'hello-world-skill',
timestamp: new Date().toISOString(),
},
});
console.log('Event captured: hello_posthog');
posthog.identify({
: ,
: {
: ,
: ,
: ,
},
});
.();
flagValue = posthog.(, );
.();
posthog.();
.();
}
().(.);