Get started
Drive native iOS and Android features from your web app with @bdk/native.
Create the client
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.
Browser method options are typed — pass the option names each method documents, and your editor will catch mismatches.
Get a command's result
Legacy dispatch commands resolve a NativeCommandResult — branch on !result.triggered. New-generation namespaced helpers resolve an Action-result envelope that always has ok — branch on !result.ok. See Handling results for the full patterns.
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 @bdk/native/browser (or the package root; CDN at dist/cdn/bdk-native.global.js) in your web app. Use @bdk/native/server or a focused /server/* entry on your backend — await returns the typed result.
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.