Configuration
Complete guide to Bklit SDK configuration options
Configuration
This guide covers all configuration options for the Bklit SDK.
Required Options
projectId
Your unique project identifier from the Bklit dashboard.
initBklit({
projectId: "your-project-id",
// ...
});Type: string
Required: Yes
Example: 'cmic3a5ap0003zxfjshgs688w'
apiKey
Your API authentication token from the Bklit dashboard.
initBklit({
apiKey: "bk_live_your-token-here",
// ...
});Type: string
Required: Yes
Format: bk_live_<64 hex characters>
Optional Options
wsHost
WebSocket server URL. Defaults to production WebSocket server.
initBklit({
wsHost: "wss://bklit.ws",
// ...
});Type: string
Default: 'wss://bklit.ws' (production) or 'ws://localhost:8080' (development)
Use cases:
- Custom WebSocket endpoint
- Development with local server
- Testing with staging environment
environment
Environment mode for the SDK.
initBklit({
environment: "production", // or 'development'
// ...
});Type: 'development' | 'production'
Default: 'production'
Effects:
- Development: Debug mode enabled by default
- Production: Optimized for performance
debug
Enable detailed console logging.
initBklit({
debug: true,
// ...
});Type: boolean
Default: false (or true if environment === 'development')
Output:
- SDK initialization logs
- Session creation logs
- Event tracking logs
- API request logs
- Error messages
Complete Example
import { initBklit } from "@bklit/sdk";
initBklit({
// Required
projectId: "your-project-id",
apiKey: "bk_live_your-token-here",
// Optional
wsHost: "wss://bklit.ws",
environment: "production",
debug: false,
});Environment-Based Configuration
Development
initBklit({
projectId: process.env.BKLIT_PROJECT_ID,
apiKey: process.env.BKLIT_API_KEY,
environment: "development",
debug: true,
});Production
initBklit({
projectId: process.env.BKLIT_PROJECT_ID,
apiKey: process.env.BKLIT_API_KEY,
environment: "production",
debug: false,
});Configuration Validation
The SDK validates configuration on initialization:
- Missing projectId: Error logged, SDK not initialized
- Invalid wsHost: Error thrown, SDK not initialized
- Invalid environment: Warning logged, uses default
Default Behavior
If options are not provided:
- wsHost:
wss://bklit.ws(production) orws://localhost:8080(development) - environment: Defaults to
'production' - debug: Defaults to
false(ortrueif development)
Best Practices
Use Environment Variables
initBklit({
projectId: process.env.NEXT_PUBLIC_BKLIT_PROJECT_ID,
apiKey: process.env.NEXT_PUBLIC_BKLIT_API_KEY,
});Enable Debug in Development
initBklit({
projectId: "your-project-id",
apiKey: "your-api-key",
debug: process.env.NODE_ENV === "development",
});Set Environment Explicitly
initBklit({
projectId: "your-project-id",
apiKey: "your-api-key",
environment:
process.env.NODE_ENV === "production" ? "production" : "development",
});Related Documentation
- Installation - Installing the SDK
- Debug Mode - Using debug mode
- API Reference - Complete API docs