Playground Setup
Set up the Bklit playground application
Playground Setup
This guide covers setting up the Bklit playground for testing SDK integration.
Prerequisites
- Bklit dashboard account
- Project created in dashboard
- API token generated
Step 1: Get Your Credentials
Create Project
- Go to your Bklit dashboard
- Create a new organization (if needed)
- Create a new project
- Note your Project ID
Generate API Token
- Go to organization settings
- Navigate to "API Tokens"
- Create a new token
- Copy the token (save it!)
Step 2: Configure Playground
Create Environment File
Create .env file in apps/playground/:
VITE_BKLIT_PROJECT_ID="your-project-id"
VITE_BKLIT_API_KEY="bk_live_your-token-here"Optional: Set API Host
For local development:
# Leave blank to use localhost:3000
# Or set to your dashboard URL
VITE_NGROK_URL="http://localhost:3000"For cloudflared tunnel:
VITE_NGROK_URL="https://abc123.trycloudflare.com"Step 3: Install Dependencies
From the root directory:
pnpm installOr from playground directory:
cd apps/playground
pnpm installStep 4: Start Playground
From Root
pnpm -F @bklit/playground devFrom Playground Directory
cd apps/playground
pnpm devThe playground will start at http://localhost:5173
Step 5: Verify Setup
- Open playground in browser
- Check browser console for SDK logs
- Navigate around the app
- Check Bklit dashboard for events
Configuration Options
Environment Variables
Required:
VITE_BKLIT_PROJECT_ID- Your project IDVITE_BKLIT_API_KEY- Your API token
Optional:
VITE_NGROK_URL- API host override
SDK Configuration
The playground uses these SDK settings:
{
projectId: import.meta.env.VITE_BKLIT_PROJECT_ID,
apiKey: import.meta.env.VITE_BKLIT_API_KEY,
apiHost: import.meta.env.VITE_NGROK_URL
? `${import.meta.env.VITE_NGROK_URL}/api/track`
: undefined,
environment: 'development',
debug: true
}Troubleshooting
Events Not Appearing
- Verify project ID is correct
- Check API token is valid
- Ensure token has project access
- Check browser console for errors
Connection Errors
- Verify dashboard is running (if using localhost)
- Check API host URL is correct
- Verify CORS is configured
- Check network tab for failed requests
SDK Not Loading
- Check environment variables are set
- Verify file is
.envnot.env.example - Restart development server
- Check browser console for errors
Related Documentation
- Testing - Using the playground
- Environment - Environment configuration
- SDK Integration - SDK documentation