Overview
Use starkzap-native when integrating StarkZap in React Native/Expo apps.
It re-exports the SDK API and adds a Metro helper (starkzap-native/metro) for runtime polyfills and resolver compatibility.
1) Install Packages
Install the React Native package and required runtime peers:
npm install starkzap-native
npm install react-native-get-random-values fast-text-encoding buffer @ethersproject/shims
Optional dependencies by feature:
# Ethereum bridge routes
npm install ethers
# Solana bridge routes
npm install @solana/web3.js @hyperlane-xyz/sdk @hyperlane-xyz/registry @hyperlane-xyz/utils
Set up Metro once and wrap your config with withStarkzap:
// metro.config.js
const { getDefaultConfig } = require("expo/metro-config");
const { withStarkzap } = require("starkzap-native/metro");
const config = getDefaultConfig(__dirname);
// Optional: add your own resolver overrides before wrapping.
module.exports = withStarkzap(config);
withStarkzap injects required polyfills and resolver handling for StarkZap dependencies.
3) Initialize the SDK
Import from starkzap-native and use the same onboarding APIs as web:
import { StarkZap, OnboardStrategy, StarkSigner } from "starkzap-native";
const sdk = new StarkZap({ network: "sepolia" });
const { wallet } = await sdk.onboard({
strategy: OnboardStrategy.Signer,
account: { signer: new StarkSigner("0xYOUR_PRIVATE_KEY") },
deploy: "if_needed",
});
For Privy-based onboarding, see Privy Integration.
4) Cartridge (native session)
When your starkzap-native version supports it, you can onboard with Cartridge using an in-app browser / deep-link session flow (not the web @cartridge/controller popup).
- Register the native Cartridge adapter once at app startup, before
connectCartridge() or onboard({ strategy: OnboardStrategy.Cartridge }). Exact export names depend on your SDK version (for example registerCartridgeTsAdapter / registerCartridgeNativeAdapter).
- Pass policies and/or a Cartridge preset that resolves policies for your chain (same concepts as Cartridge Controller).
- Align
rpcUrl / chainId (or network) on new StarkZap({ ... }) with the session and paymaster you target.
- Deploy: native Cartridge flows often default to
deploy: "never" or recommend it when deployment semantics differ from the browser Controller. Pass deploy: "if_needed" explicitly if you need core-style deployment checks.
- Fees: sponsored execution on native is tied to the session wallet (commonly
feeMode: "sponsored" only for matching policy paths).
See Cartridge Controller for policy and paymaster behavior, and the examples/tic-tac-toe app in the Starkzap repository when available for a full Expo reference.
5) External Wallet Providers (Optional)
If your app uses WalletConnect/Reown for external wallets, initialize its RN compatibility layer at app startup:
import "@walletconnect/react-native-compat";
Then pass the resulting providers into StarkZap external wallet adapters as described in Bridging.
If connectCartridge or Cartridge onboarding throws not implemented, your installed starkzap-native build does not ship the native adapter yet — upgrade to a version that documents native Cartridge, or use Signer / Privy until then.
Next Steps