Skip to content

Export Wallet on React Native

Reveal the seed phrase or private key via WebView

The web export hooks (useExportWallet and useExportPrivateKey) are not available on React Native.

Export can't go through a plain hook — the secret must never touch your JS. Use ZeroDevExportWebView instead: it renders Turnkey's export iframe inside an isolated WebView, so the plaintext stays in the iframe's context.

1. Install peer dependencies

It needs react-native-webview and uuid (native module — rebuild the dev client afterwards):

npm
npx expo install react-native-webview uuid
npx expo run:android   # or: npx expo run:ios

2. Add the component

import { ZeroDevExportWebView } from "@zerodev/wallet-react/react-native/export/webview";
import { useState } from "react";
import { Button, Text } from "react-native";
 
export function ExportWallet() {
  const [show, setShow] = useState(false);
  const [ready, setReady] = useState(false);
  const [error, setError] = useState<string | null>(null);
 
  return (
    <>
      <Button title="Export wallet" onPress={() => setShow(true)} />
 
      {show && !ready && !error ? <Text>Loading…</Text> : null}
      {error ? <Text style={{ color: "red" }}>{error}</Text> : null}
 
      {show && !error ? (
        <ZeroDevExportWebView
          kind="wallet"
          onReady={() => setReady(true)}
          onError={(message) => setError(message)}
          style={ready ? { height: 240 } : { height: 0 }}
        />
      ) : null}
    </>
  );
}
  • onReady fires once the secret is on screen → flips ready, which clears the "Loading…" line and gives the WebView its height.
  • onError captures the message → the !error guard unmounts the WebView and the red error line shows instead.
  • The loading message shows while mounted-but-not-yet-ready (show && !ready && !error).
  • Use kind="privateKey" to export the account's private key instead of the seed phrase.

See the ZeroDevExportWebView reference for the full props.

How it stays secure

Mounting the component starts the export; unmounting it dismisses the secret. The decrypted seed phrase or private key is only ever rendered inside Turnkey's export iframe within the WebView — it never crosses into your app's JavaScript context.