Use with AI agents

Point Lovable, Cursor, Replit, and other AI coding tools at the SDK so they generate correct, secure code.

Built for AI agents

Read llms.txt for the page index, then fetch the pages needed for the task. llms-full.txt is for tools that index the full reference.

Prime your agent

Drop this into your agent's context before you ask it to build a native feature.

You are adding native features with @thebdk/native.
Read https://docs.thebdk.com/llms.txt and fetch the relevant reference pages.
Install: npm install @thebdk/native
Use one client per page; setup: https://docs.thebdk.com/getting-started/initializing-the-client.
Supported namespaces include app, navigation, ui, device, location, media, auth, iap, share, permissions, push, notifications, att, contacts, badge, deeplink, health, nfc and capabilities. Use only documented public helpers.
Rules:
- Legacy commands return NativeCommandResult. Use !result.triggered; subscribe before calling a helper whose data arrives on an event.
- Envelope helpers return an ok result. Use isBdkError(result) or !result.ok; do not read triggered on them.
- New iap and health helpers can also return a bare command result. Check "ok" in result before result.ok.
- Detect native UI at startup with environment() or ready(3000); wait for device info before platform-dependent calls. Do not use native detection as authentication.
- Use capabilities.has() before showing optional feature UI. Return or render the web path when unavailable.
- Wrap calls that can reject in try/catch. Never publish internal commands or version gates.
- Server helpers stay on the backend. Read credentials from its environment; authenticate and authorize callers, and select push recipients on the server.
- Project setup, preview, checkout and BDK builds: https://thebdk.com/agent/skill.md. The customer submits to the stores.

The patterns to follow

Legacy commands return NativeCommandResult; use !result.triggered and subscribe before calls whose data arrives on events. A browser tab returns pending, while a runtime without window returns skipped. Envelope helpers return { ok: true, ... } or { ok: false, code, message }; use isBdkError(result) or !result.ok, not triggered. New iap.* and health.* helpers can also return a bare command result: check "ok" in result first. Read each helper’s result type; do not apply one check to all methods.

Use one client per page. Detect native UI at startup and wait for device info before platform-dependent calls. Keep keys on the backend; authentication and permission checks belong there too.

import { bdk } from "~/lib/bdk";

// Call from the native path after startup detection has settled.
const off = bdk.on("photoCaptured", (photo) => showPhoto(photo.fileUrl));
try {
  const result = await bdk.media.capturePhoto();
  if (!result.triggered) openWebFilePicker();
} catch {
  showCameraUnavailable();
}
// Keep the listener while this UI is active; call off() when it unmounts.

Set up the app with your AI

To create, preview, pay for and build the BDK project, follow https://thebdk.com/agent/skill.md. Connection steps: https://thebdk.com/agent. These are service tasks; this docs set covers SDK code.

Keys stay in the environment

Agents copy your examples closely, so every example here reads credentials from the environment. Follow the same rule: pass keys from env (or a secrets manager), never in client code or source.

Server helpers read their credentials from arguments or environment variables. Don't hardcode API keys, and never ship a server import to the browser.

import { sendPushNotification } from "@thebdk/native/server/onesignal";

await sendPushNotification({
  message: "Your order shipped",
  playerIds: [playerId],
  oneSignalAppId: process.env.ONESIGNAL_APP_ID,
  oneSignalApiKey: process.env.ONESIGNAL_API_KEY
});