Installation
Install and configure HydrateBeer in your project
Automated Setup (Recommended)
The fastest way to get started:
npx hydrate-beer-cli initThis interactive CLI will:
- Detect your project type (Next.js/React)
- Generate a unique project ID
- Set up password protection for monitoring
- Configure PostHog integration
- Create configuration files
- Install the SDK automatically
Manual Installation
If you prefer manual setup:
1. Install the SDK
npm install hydrate-beeryarn add hydrate-beerpnpm add hydrate-beerbun add hydrate-beer2. Create PostHog Account
- Sign up at posthog.com
- Create a new project
- Copy your Project API Key
3. Configure Environment Variables
Create .env.local (Next.js) or .env (Vite/CRA):
NEXT_PUBLIC_HYDRATE_BEER_PROJECT_ID=proj_your_generated_id
NEXT_PUBLIC_HYDRATE_BEER_POSTHOG_API_KEY=phc_your_posthog_keyFor Vite/CRA, use VITE_ prefix:
VITE_HYDRATE_BEER_PROJECT_ID=proj_your_generated_id
VITE_HYDRATE_BEER_POSTHOG_API_KEY=phc_your_posthog_key4. Add Provider
See Quick Start for framework-specific integration.
PostHog Setup
Cloud Hosting
PostHog offers free cloud hosting with generous limits:
- US Cloud:
https://us.posthog.com - EU Cloud:
https://eu.posthog.com
Select the instance closest to your users for best performance.
Self-Hosted
If you self-host PostHog:
<HydrateBeerProvider
config={{
projectId: '...',
posthogApiKey: '...',
posthogHost: 'https://your-posthog-instance.com',
}}
>Verify Installation
- Start your dev server
- Open browser console
- Look for:
HydrateBeer: Initialized successfully - Check PostHog dashboard for incoming events
Requirements
- React 17+ or React 18+
- Next.js 12+ (for Next.js projects)
- Modern browser with
fetchAPI - PostHog account (free)
TypeScript Support
HydrateBeer is written in TypeScript and includes full type definitions:
import type { HydrateBeerConfig } from 'hydrate-beer-sdk';
const config: HydrateBeerConfig = {
projectId: 'proj_...',
posthogApiKey: 'phc_...',
posthogHost: 'https://us.posthog.com',
sampleRate: 1.0,
slowRenderThreshold: 16,
flushInterval: 5000,
batchSize: 50,
};