@doordeck/headless-react-native-sdk

中文文档
1.0.67发布于 2026/11/10MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4241

Doordeck React Native headless SDK

原始使用文档
文档目录10 节
  1. Overview
  2. Installation
  3. iOS
  4. Usage
  5. Importing the SDK
  6. Authentication Methods
  7. Device and Tile Operations
  8. Error Handling
  9. License
  10. Support

@doordeck/headless-react-native-sdk

Overview

The @doordeck/headless-react-native-sdk is a lightweight React Native SDK built on top of the Doordeck SDK. This SDK provides a minimal interface for authentication and lock management, focusing on user-facing operations. It enables React Native applications to authenticate users, manage authentication tokens, retrieve lock details, and unlock devices via Doordeck's platform.

Installation

To install the SDK, ensure you have React Native set up in your project, then add the necessary dependencies:

npm install @doordeck/headless-react-native-sdk

or using yarn:

yarn add @doordeck/headless-react-native-sdk

iOS

After installing the package, install the pods:

cd ios && pod install

The native Doordeck SDK is pulled in automatically as a CocoaPods dependency (DoordeckSDK, a dynamic xcframework) and embedded into your app by CocoaPods — no extra Podfile configuration or build phases are required. The SDK works with the default static-library linkage as well as with use_frameworks! (both :static and :dynamic).

Usage

Importing the SDK

Import every single method according to your usage

import { login } from '@doordeck/headless-react-native-sdk';
// ...
import { logout } from '@doordeck/headless-react-native-sdk';

Authentication Methods

login(email: string, password: string): Promise<AssistedRegisterEphemeralKeyResponse>

Logs the user in with their email and password.

Note: If login is performed without verification within the same session, authentication will only persist in runtime memory and will be lost when the app restarts.

import { login } from '@doordeck/headless-react-native-sdk';

login("[email protected]", "password123")
  .then(response => console.log("Login successful", response))
  .catch(error => console.error("Login failed", error));

setAuthToken(authToken: string): Promise<AssistedRegisterEphemeralKeyResponse>

Sets an authentication token manually.

Note: Like login, authentication without verification will only persist in runtime memory and will be lost after the app restarts.

import { setAuthToken } from '@doordeck/headless-react-native-sdk';

setAuthToken("your-auth-token")
  .then(response => console.log("Token set successfully", response))
  .catch(error => console.error("Error setting token", error));

verify(code: string): Promise<void>

Verifies an ephemeral key registration with a verification code. Upon successful verification, the user ID and authentication context are saved in persistent storage.

import { verify } from '@doordeck/headless-react-native-sdk';

verify("123456")
  .then(() => console.log("Verification successful"))
  .catch(error => console.error("Verification failed", error));

logout(): Promise<void>

Logs out the current user and clears the stored authentication context, including removing the persistent user ID.

import { logout } from '@doordeck/headless-react-native-sdk';

logout()
  .then(() => console.log("Logged out"))
  .catch(error => console.error("Logout failed", error));

Device and Tile Operations

getLocksBelongingToTile(tileId: string): Promise<TileLocksResponse>

Retrieves a list of locks associated with a specific tile.

import { getLocksBelongingToTile } from '@doordeck/headless-react-native-sdk';

getLocksBelongingToTile("tile-uuid")
  .then(response => console.log("Locks: ", response))
  .catch(error => console.error("Failed to get locks", error));

unlockDevice(lockId: string): Promise<void>

Unlocks a device given its lock ID.

import { unlockDevice } from '@doordeck/headless-react-native-sdk';

unlockDevice("lock-uuid")
  .then(() => console.log("Device unlocked"))
  .catch(error => console.error("Unlock failed", error));

Error Handling

Each method returns a Promise. If an error occurs, the catch block will handle the failure, returning an error object containing an error code and message.

License

This SDK follows the Doordeck licensing agreement. Ensure compliance with Doordeck's API usage policies before integrating this SDK into your project.

Support

For additional support, refer to the Doordeck Developer Documentation.

版本与发布记录

@doordeck/headless-react-native-sdk 共发布 63 个版本,首次发布于 2025/03/11;过去 12 个月发布了 61 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.67latest2026/11/103 天前
1.0.662026/11/094 天前
1.0.652026/11/094 天前
1.0.642026/11/094 天前
1.0.632026/11/0211 天前
1.0.622026/11/0211 天前

关于 @doordeck/headless-react-native-sdk 的常见问题

@doordeck/headless-react-native-sdk 是什么?

Doordeck React Native headless SDK

如何安装 @doordeck/headless-react-native-sdk?

在项目目录运行 npm install @doordeck/headless-react-native-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.0.0)、react-native(>=0.86.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@doordeck/headless-react-native-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@doordeck/headless-react-native-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@doordeck/headless-react-native-sdk 可以商用吗?

@doordeck/headless-react-native-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@doordeck/headless-react-native-sdk 的下载量有多少?

根据 npm 官方下载统计,@doordeck/headless-react-native-sdk 在 2026/10/13 – 2026/11/11 这 30 天内被下载 4,241 次,日均约 141 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@doordeck/headless-react-native-sdk 还在维护吗?

最新版本 1.0.67 发布于 2026/11/10(3 天前);至今共发布 63 个版本,其中过去 12 个月发布了 61 个;首次发布于 2025/03/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。