Skip to main content
The useExportPrivateKey hook returns a URL where the user can reauthenticate and view their private key. On React Native, you open this URL in the system browser or an in-app browser.

Integration

import { useExportPrivateKey, useWallet } from "@getpara/react-native-wallet";
import { Button, Alert, Linking } from "react-native";

export function ExportKeyButton() {
  const { data: wallet } = useWallet();
  const { exportPrivateKeyAsync, isPending } = useExportPrivateKey();

  const handleExport = async () => {
    try {
      const { url } = await exportPrivateKeyAsync({
        walletId: wallet?.id,
      });

      if (url) {
        const canOpen = await Linking.canOpenURL(url);
        if (canOpen) {
          await Linking.openURL(url);
        } else {
          Alert.alert("Error", "Unable to open export URL");
        }
      }
    } catch (err) {
      console.error("Failed to export private key:", err);
      Alert.alert("Error", "Failed to initiate private key export");
    }
  };

  return (
    <Button
      title={isPending ? "Loading..." : "Export Private Key"}
      onPress={handleExport}
      disabled={isPending || !wallet}
    />
  );
}
For a better user experience, consider using expo-web-browser or react-native-inappbrowser-reborn to open the export URL within your app instead of leaving it.

Limitations

Currently, private key export is only available for embedded EVM or Cosmos wallets which are not pregenerated or guest mode wallets.
The key exported will work as either an EVM or Cosmos private key, depending on what wallet it is imported into.