initialize(options) Initializes the DropOnAir client. On first call it generates an X25519 keypair, stores it securely, publishes the public key to your key directory, exchanges a token, and opens the WebSocket connection.
JavaScript Android iOS
Returns a Promise<DropOnAirClient>.
import { initialize } from '@droponair/sdk-js' ;
const client = await initialize ({
appId: 'your-app-id' ,
publicApiKey: 'your-public-api-key' ,
getUserJwt: () => fetch ('/api/auth/token' ).then (r => r.text ()),
tokenExchangeEndpoint: '/api/droponair/token' ,
keyDirectoryEndpoint: '/api/droponair/keys' ,
});Options Option Type Required Description appId string Yes Your DropOnAir App ID from the dashboard publicApiKey string Yes Your public API key, safe to expose client-side getUserJwt () => Promise<string> Yes Callback that returns a fresh JWT from your backend. Called on connect and token refresh. tokenExchangeEndpoint string No Your backend endpoint that calls DropOnAir token exchange keyDirectoryEndpoint string No Your backend endpoint base for PUT/GET public keys autoConnect boolean No Auto-connect on initialization. Default: true autoAckIncomingMessages boolean No Auto-send PROCESSED ack after decryption. Set false for manual ack. Default: true storage KeyStorageAdapter No Custom key storage. Default: IndexedDB with in-memory fallback fetchFn typeof fetch No Custom fetch (e.g. for React Native). Default: globalThis.fetch debug boolean No Verbose diagnostic logs for all SDK operations