Get started
Drive native iOS and Android features from your web app with @bdk/native.
Create the client
@bdk/native lets your web app use native iOS and Android features — camera, location, in-app purchases, and more — when it runs inside the BDK Native shell. Create the client once with createBdkNative() and reuse it everywhere.
Always create the client with createBdkNative(), never new BdkNativeClient(). It's ready the moment it returns.
Detect the native app
Use bdk.ready(timeoutMs) to wait for device info and bdk.isNative() to branch your code. In a plain browser there's no app, so render a web-only fallback.
bdk.ready(0)(the default) resolves immediately — cachedBdkDeviceInfoif it arrived, elsenull.bdk.ready(3000)waits up to the timeout (ms) for thedeviceInfoevent.
Option keys you pass to browser methods are the native command contract — pass exactly the keys each native command expects.
Get a command's result
Sending a command and receiving its result are two steps. Every browser method returns a Promise<NativeCommandResult> (see Objects) that only confirms the command was dispatched. Device data arrives later on an event you subscribe to with bdk.on(event, listener), which returns an unsubscribe function. Subscribe before you dispatch.
There are three result shapes:
- Dispatch-and-forget — commands like navigation.
awaitconfirms dispatch; no follow-up event. - Dispatch + event — anything that returns device data: media (
photoSelected,photoCaptured,videoSelected,videoCaptured),location, pickers (datePicked,optionPicked),biometricResult, purchases (purchaseSuccess,purchaseFailed,receiptReceived, …). Read the payload from the matching event. - Resolved value — the server SDK.
awaitreturns the real outcome (see below).
Match the event to the command: bdk.media.capturePhoto() emits photoCaptured, bdk.media.pickPhoto() emits photoSelected. Both deliver a MediaResult ({ fileUrl, dataUri, data, contentType }).
Browser and server SDKs
Use the browser SDK in your web app and the server SDK on your backend. Awaiting a server call resolves to the real, typed result.
Browser SDK — @bdk/native/browser (re-exported from @bdk/native). The client shown above. A CDN global build is at dist/cdn/bdk-native.global.js.
Server SDK — @bdk/native/server, plus focused entry points @bdk/native/server/onesignal, /server/iap, /server/branch, /server/chottulink, and /server/firebase-dynamic-links. For example, sendPushNotification(input) returns a PushNotificationResult with notificationId, numberOfRecipients, and sentSuccessfully.
Never import @bdk/native/server/* into a browser bundle — those modules are server-only and may carry secrets. Only the root and /browser entry points are browser-safe.
Start an in-app purchase
Dispatch a purchase with bdk.iap.purchaseIos(), identifying the product with { id, type } where type is "product" or "subscription". Read the outcome from the purchaseSuccess or purchaseFailed event.