@crossmint/client-sdk-react-native-ui

中文文档
2.1.7发布于 2026/11/10Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 7.2万

React Native SDK for integrating Crossmint Wallets into your mobile application. Provides providers, hooks, and built-in UI for wallet creation, signing, and OTP verification.

原始使用文档
文档目录19 节
  1. Prerequisites
  2. Installation
  3. Xcode 27 and iOS 27
  4. Quick Start
  5. 1. Setup Providers
  6. 2. Use Wallets
  7. Providers
  8. CrossmintWalletProvider Props
  9. Hooks
  10. useWallet()
  11. useWalletOtpSigner()
  12. useCrossmintAuth()
  13. Components
  14. ExportPrivateKeyButton
  15. Differences from React SDK
  16. Wallets SDK
  17. Environment Setup
  18. Documentation
  19. License

@crossmint/client-sdk-react-native-ui

React Native SDK for integrating Crossmint Wallets into your mobile application. Provides providers, hooks, and built-in UI for wallet creation, signing, and OTP verification.

Prerequisites

Get a client API key from the Crossmint developer console. Ensure your key has the Wallet API scopes enabled, including wallets.fund for stagingFund.

Installation

npx expo install @crossmint/client-sdk-react-native-ui expo-constants expo-device expo-secure-store expo-web-browser react-native-get-random-values react-native-webview

The SDK requires Expo SDK 58 (React Native 0.88, iOS 16.4 or later). The native modules are peer dependencies, and npx expo install picks the versions that match your Expo SDK.

Xcode 27 and iOS 27

Apps built with Xcode 27 (the iOS 27 SDK) must use the UIKit scene lifecycle. If they do not, they stop at launch with "UIScene life cycle is required for apps built with this SDK". Expo SDK 58 generates it: npx expo prebuild adds a SceneDelegate.swift and a scene manifest to Info.plist. No configuration is needed, and the Crossmint config plugin works with it.

After you upgrade to Expo SDK 58, regenerate the native project. If your app generates ios/ and android/ (continuous native generation), run npx expo prebuild --clean. If you maintain those folders by hand, --clean deletes your changes; apply the scene lifecycle changes to your own AppDelegate and Info.plist instead, as described in Expo's iOS scene lifecycle guide.

If your app config still sets ios.enableSceneSupport in expo-build-properties, you can remove it. It has no effect on Expo SDK 58.

Quick Start

1. Setup Providers

With Crossmint Auth (default in staging)

import {
  CrossmintProvider,
  CrossmintAuthProvider,
  CrossmintWalletProvider,
} from "@crossmint/client-sdk-react-native-ui";

export default function App() {
  return (
    <CrossmintProvider apiKey={process.env.EXPO_PUBLIC_CROSSMINT_API_KEY}>
      <CrossmintAuthProvider>
        <CrossmintWalletProvider
          createOnLogin={{
            chain: "base-sepolia",
            recoveryMethods: [{ type: "email" }],
          }}
        >
          <MainApp />
        </CrossmintWalletProvider>
      </CrossmintAuthProvider>
    </CrossmintProvider>
  );
}

Bring Your Own Authentication

Use this when your app already has an auth provider, and in production: connect your provider and configure JWT Authentication in the Crossmint Console (see Move to Production). Then skip CrossmintAuthProvider and pass your provider's JWT to the wallets SDK. See the Custom Auth Guide for full details.

import {
  CrossmintProvider,
  CrossmintWalletProvider,
} from "@crossmint/client-sdk-react-native-ui";

export default function App() {
  return (
    <CrossmintProvider apiKey={process.env.EXPO_PUBLIC_CROSSMINT_API_KEY}>
      <CrossmintWalletProvider
        createOnLogin={{
          chain: "base-sepolia",
          recoveryMethods: [
            {
              type: "email",
              email: "[email protected]",
            },
          ],
        }}
      >
        <MainApp />
      </CrossmintWalletProvider>
    </CrossmintProvider>
  );
}

2. Use Wallets

import { useWallet } from "@crossmint/client-sdk-react-native-ui";
import { View, Text, TouchableOpacity } from "react-native";

function WalletActions() {
  const { wallet, status } = useWallet();

  if (status === "in-progress") return <Text>Loading wallet...</Text>;
  if (!wallet) return <Text>No wallet</Text>;

  // Staging only: mints USDXM, Crossmint's test stablecoin, into the wallet
  const handleFund = async () => {
    await wallet.stagingFund(10);
  };

  const handleSend = async () => {
    const tx = await wallet.send("0xRecipient", "usdxm", "10");
    console.log("Transaction:", tx.explorerLink);
  };

  return (
    <View>
      <Text>Wallet: {wallet.address}</Text>
      <TouchableOpacity onPress={handleFund}>
        <Text>Get 10 USDXM</Text>
      </TouchableOpacity>
      <TouchableOpacity onPress={handleSend}>
        <Text>Send 10 USDXM</Text>
      </TouchableOpacity>
    </View>
  );
}

Providers

ProviderPurpose
CrossmintProviderRoot provider. Required for all Crossmint features.
CrossmintAuthProviderAuthentication (OAuth). Optional if using your own auth.
CrossmintWalletProviderWallet creation, device signer management, and OTP UI.

CrossmintWalletProvider Props

PropTypeDefaultDescription
createOnLoginCreateOnLogin—Auto-create wallet on auth. Uses recovery or recoveryMethods + optional signers.
showOtpSignerPromptbooleantrueWhen true (default), built-in OTP dialogs are shown during signing flows. Set to false to suppress them and handle OTP manually via useWalletOtpSigner().
deviceSignerKeyStorageDeviceSignerKeyStorage—Override the default native key storage.
passkeysNativePasskeyConfig—Enables passkey signers on every chain: { rpId, rpName?, passkey: Passkey }, with Passkey from react-native-passkey. Requires an app associated with rpId (iOS webcredentials: associated domain, Android Digital Asset Links) and a development build, since Expo Go cannot run native modules. Keep rpId fixed once users have created passkeys. Without this prop, passkey signers are rejected.
appearanceUIConfig—Styling for built-in UI components.

Hooks

useWallet()

Returns the wallet instance and management functions:

const {
  wallet,              // Wallet | undefined
  status,              // "not-loaded" | "in-progress" | "loaded" | "error"
  getWallet,           // (props: { chain, alias? }) => Promise<Wallet | undefined>
  createWallet,        // (props: ClientSideWalletCreateArgs) => Promise<Wallet | undefined>
  createDeviceSigner,  // () => Promise<DeviceSignerDescriptor> | undefined
  createPasskeySigner, // (name: string) => Promise<RegisterSignerPasskeyParams>
} = useWallet();

useWalletOtpSigner()

For custom OTP UI when using email/phone recovery methods. When showOtpSignerPrompt is set to false, use this hook to handle OTP flows manually:

const { needsAuth, sendOtp, verifyOtp, reject } = useWalletOtpSigner();

useCrossmintAuth()

Authentication state and OAuth login:

const { loginWithOAuth, logout, user } = useCrossmintAuth();

// OAuth providers
loginWithOAuth("google");
loginWithOAuth("twitter");

Components

ExportPrivateKeyButton

Renders a button to export the wallet's private key via TEE. Only renders for email/phone signers.

import { ExportPrivateKeyButton } from "@crossmint/client-sdk-react-native-ui";

<ExportPrivateKeyButton appearance={{ borderRadius: "12px" }} />

Differences from React SDK

FeatureReactReact Native
Device signer storageBrowser iframe (IframeDeviceSignerKeyStorage)Native secure storage (iOS Secure Enclave / Android Keystore)
Device storage overrideNot exposeddeviceSignerKeyStorage prop on provider
Built-in OTP UIAlways renderedshowOtpSignerPrompt=true (shown by default)
Passkey helper UIshowPasskeyHelpers propNot available
TEE communicationHidden iframeHidden WebView (lazily initialized)

Wallets SDK

The wallet object returned by useWallet() is a Wallet instance. For wallet method documentation (send, balances, sign, etc.), see the @crossmint/wallets-sdk README.

Environment Setup

  1. Get your API key from Crossmint Console

  2. Add to your .env:

EXPO_PUBLIC_CROSSMINT_API_KEY=your_api_key_here
  1. Configure deep linking in app.json:
{
  "expo": {
    "scheme": "your-app-scheme"
  }
}

Documentation

License

Apache-2.0

版本与发布记录

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

版本发布日期距今
2.1.7latest2026/11/10今天
2.1.62026/11/074 天前
2.1.52026/11/064 天前
2.1.42026/11/065 天前
2.1.32026/11/056 天前
2.1.22026/11/056 天前

其他发布通道:beta → 1.0.0-beta.7,legacy → 0.13.34。

关于 @crossmint/client-sdk-react-native-ui 的常见问题

@crossmint/client-sdk-react-native-ui 是什么?

React Native SDK for integrating Crossmint Wallets into your mobile application. Provides providers, hooks, and built-in UI for wallet creation, signing, and OTP verification.

如何安装 @crossmint/client-sdk-react-native-ui?

在项目目录运行 npm install @crossmint/client-sdk-react-native-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(^58.0.0)、react(>=17.0.2)、expo-device(^58.0.0)、react-native(>=0.74.3)、expo-constants(^58.0.0)、@solana/web3.js(^1.98.1)、expo-web-browser(^58.0.0)、expo-secure-store(^58.0.0)、react-native-webview(^14.0.1)、react-native-get-random-values(>=1.11.0 <3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@crossmint/client-sdk-react-native-ui 支持 TypeScript 吗?

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

@crossmint/client-sdk-react-native-ui 支持 ESM 还是 CommonJS?

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

@crossmint/client-sdk-react-native-ui 可以商用吗?

@crossmint/client-sdk-react-native-ui 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@crossmint/client-sdk-react-native-ui 的下载量有多少?

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

@crossmint/client-sdk-react-native-ui 还在维护吗?

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