# Export Private Key

Allow users to export their wallet’s private key for backup or migration. Openfort’s SDK provides:

* Secure export flows for embedded wallets
* Warnings and best practices for key management
* Options to restrict export based on user status

Key export empowers users with control over their assets, while maintaining security and clarity in the export process.

To export the private key of the embedded wallet, use the `useEthereumEmbeddedWallet` or `useSolanaEmbeddedWallet` hook. Both provide `exportPrivateKey` for securely exporting the wallet's private key.

## Code examples

:::code-group
```tsx [Ethereum]
import { useEthereumEmbeddedWallet } from "@openfort/react/ethereum"

function ExportKey() {
  const { exportPrivateKey } = useEthereumEmbeddedWallet() // [!code focus]

  const handleExport = async () => {
    const privateKey = await exportPrivateKey()
    console.log("Private key:", privateKey)
  }

  return <button onClick={handleExport}>Export private key</button>
}
```

```tsx [Solana]
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"

function ExportKey() {
  const { exportPrivateKey } = useSolanaEmbeddedWallet()

  const handleExport = async () => {
    const privateKey = await exportPrivateKey()
    console.log("Private key:", privateKey)
  }

  return <button onClick={handleExport}>Export private key</button>
}
```
:::
