initAmplifySDK() once at application startup.
initAmplifySDK()
Function Signature
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your Paxos Labs API key (format: pxl_...) |
options | SDKInitOptions | No | Configuration options for telemetry and logging |
SDKInitOptions
| Option | Type | Default | Description |
|---|---|---|---|
telemetry | boolean | true | Enable PostHog error tracking |
logLevel | LogLevel | LogLevel.ERROR | Minimum log level to output |
logger | Logger | Built-in console logger | Custom logger implementation |
Usage Examples
Basic Initialization
With Telemetry Disabled
With Debug Logging
With All Options
React Integration
Create a hook to initialize the SDK once and expose ready state:Behavior
- Validates API key - Ensures key follows expected format
- Pre-populates cache - Fetches vaults and assets during initialization
- Configures telemetry - Sets up PostHog if enabled
- Configures logging - Sets log level and optional custom logger
- Idempotent - Multiple calls with same key are no-ops
- Re-initialization - Different key clears cache and reconfigures
Error Handling
| Error Code | Description | Resolution |
|---|---|---|
SDK_NOT_INITIALIZED | SDK used before initAmplifySDK() | Call initAmplifySDK() first |
INVALID_API_KEY | API key validation failed | Check API key format |