Playground Environment

Environment variables and configuration for the playground

Playground Environment

This guide covers environment variables and configuration for the Bklit playground.

Environment Variables

Required Variables

VITE_BKLIT_PROJECT_ID

  • Your Bklit project ID
  • Get from dashboard → Project Settings
  • Format: CUID string

VITE_BKLIT_API_KEY

  • Your API token
  • Get from dashboard → API Tokens
  • Format: bk_live_<64 hex characters>

Optional Variables

VITE_NGROK_URL

  • API host override for remote testing
  • Leave blank to use localhost:3000
  • Set when using tunnels or custom hosts
  • Examples:
    • ngrok: https://abc123.ngrok.io
    • cloudflared: https://abc123.trycloudflare.com
    • production: Leave blank

Environment File

Create .env in apps/playground/:

# Required
VITE_BKLIT_PROJECT_ID="your-project-id"
VITE_BKLIT_API_KEY="bk_live_your-token-here"

# Optional
# VITE_NGROK_URL="http://localhost:3000"

Configuration

Default Configuration

The playground uses these defaults:

  • Environment: development
  • Debug: true
  • API Host: http://localhost:3000/api/track (if not set)

Custom Configuration

Modify apps/playground/src/main.tsx to change SDK configuration.

Development vs Production

Development

VITE_BKLIT_PROJECT_ID="dev-project-id"
VITE_BKLIT_API_KEY="dev-token"
VITE_NGROK_URL="http://localhost:3000"

Testing with Production

VITE_BKLIT_PROJECT_ID="prod-project-id"
VITE_BKLIT_API_KEY="prod-token"
# Leave VITE_NGROK_URL blank for production API

Using Tunnels for Remote Testing

When You Need Tunnels

  • Testing from mobile devices
  • Webhook testing (Polar, Resend)
  • Sharing with team members
  • Testing OAuth callbacks

1. Install and start:

# Terminal 1: Dashboard
pnpm -F @bklit/dashboard dev

# Terminal 2: ngrok
ngrok http 3000

2. Copy HTTPS URL: https://abc123.ngrok.io

3. Update playground .env:

VITE_NGROK_URL="https://abc123.ngrok.io"

4. Restart playground to use new URL

Option 2: Cloudflare Tunnel

# Start tunnel
cloudflared tunnel --url http://localhost:3000

Set in .env:

VITE_NGROK_URL="https://abc123.trycloudflare.com"

Production Testing

For production API testing, leave VITE_NGROK_URL blank:

# .env - production testing
VITE_BKLIT_PROJECT_ID="prod-project-id"
VITE_BKLIT_API_KEY="prod-token"
# VITE_NGROK_URL - leave blank or remove

Security Notes

  • Never commit .env file
  • Use test project for playground
  • Rotate tokens regularly
  • Don't share tokens publicly

Troubleshooting

Variables Not Loading

  • Check file is .env not .env.example
  • Verify variable names start with VITE_
  • Restart development server
  • Check for typos

Wrong API Host

  • Verify VITE_NGROK_URL is correct
  • Check dashboard is running
  • Verify CORS configuration
  • Test API endpoint directly

On this page