Install and import

Install @bdk/native and pick the right import for browser or server code.

Install the package

Add @bdk/native with your package manager. Server code needs Node.js 18 or newer.

npm install @bdk/native

Import for app code

Import from @bdk/native for a single, obvious import path in app code. Use createBdkNative() to create a ready-to-use client.

The root and /browser entries resolve to the same module. Pick whichever import path reads best.

import { createBdkNative } from "@bdk/native";

export const bdk = createBdkNative();

Import in the WebView

Use @bdk/native/browser for code that runs inside the WebView or a browser. It exports createBdkNative, BdkNativeClient, NativeBridge, the error helpers, and the browser types (BdkNativeConfig, NavigateOptions, LoadingScreenOptions, OpenLinkOptions, UrlParam, PermissionName).

Pass a BdkNativeConfig to tune behavior — common fields are removeLoading ("automatic" or "manual"), pageFit, autoRequestDeviceInfo, and an onError callback that receives a BdkError. Browser method options are passed straight through to the native command — match the key names it expects.

Awaiting a browser namespace method resolves when the call is sent, not when the native action finishes. For real resolved results, use the server helpers below.

import { createBdkNative } from "@bdk/native/browser";

export const bdk = createBdkNative();

Import on the server

Use the @bdk/native/server entries for Node code — push notifications, receipt validation, deep links. These helpers are fully typed and return real resolved results.

Import the aggregate @bdk/native/server, or a single concern to keep your bundle lean:

  • @bdk/native/server/onesignal — push notifications (e.g. sendPushNotification)
  • @bdk/native/server/iap — receipt validation (e.g. verifyIosReceipt, verifyAndroidReceipt, consumeAndroidPurchase)
  • @bdk/native/server/branch — Branch deep links
  • @bdk/native/server/chottulink — ChottuLink deep links
  • @bdk/native/server/firebase-dynamic-links — Firebase Dynamic Links

Never import a @bdk/native/server/* module into browser code — it pulls in Node-only dependencies and breaks the build.

import { sendPushNotification } from "@bdk/native/server";

const result = await sendPushNotification({
  oneSignalAppId: process.env.ONESIGNAL_APP_ID,
  oneSignalApiKey: process.env.ONESIGNAL_API_KEY,
  title: "Hello",
  message: "Your order shipped"
});

Use without a bundler (CDN)

Drop in the prebuilt IIFE bundle to use the SDK without a bundler. It is published to unpkg and jsdelivr and attaches a BdkNative global to window, so createBdkNative is available as BdkNative.createBdkNative. Server helpers are not included.

<script src="https://unpkg.com/@bdk/native/dist/cdn/bdk-native.global.js"></script>
<script>
  const bdk = BdkNative.createBdkNative();
</script>

Browser-safe vs server-only

The root, /browser, and the CDN global build are browser-safe. Every /server entry and subpath is server-only.

The single rule that prevents most build failures: never import @bdk/native/server/* into anything that ships to the browser.

import { createBdkNative } from "@bdk/native";          // root
import { BdkNativeClient } from "@bdk/native/browser";   // browser