> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Exporting WaaS Private Key

You can securely export the private key for a WaaS wallet account.
For that, you'll need to specify an HTML element to be used to inject an iframe containing the private key.

### Usage

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"system"}
    import { exportWaasPrivateKey, isWaasWalletAccount } from '@dynamic-labs-sdk/client/waas';
    import { client } from './client';

    const exportPrivateKey = async () => {
      const walletAccounts = client.wallets.getWalletAccounts();
      const walletAccount = walletAccounts[0];

      if (!isWaasWalletAccount(walletAccount)) return;

      await exportWaasPrivateKey({
        walletAccount,
        displayContainer: document.getElementById('display-container'),
      });
    };

    // Add a container in your UI to inject the iframe
    // E.g: <div id="display-container"></div>
    ```
  </Tab>

  <Tab title="React">
    Use a `ref` to pass the DOM element to `exportWaasPrivateKey`:

    ```tsx theme={"system"}
    import { exportWaasPrivateKey, isWaasWalletAccount } from '@dynamic-labs-sdk/client/waas';
    import { getWalletAccounts } from '@dynamic-labs-sdk/client';
    import { useRef } from 'react';

    function ExportPrivateKey() {
      const containerRef = useRef<HTMLDivElement>(null);

      const handleExport = async () => {
        const walletAccounts = getWalletAccounts();
        const walletAccount = walletAccounts[0];

        if (!walletAccount || !isWaasWalletAccount(walletAccount) || !containerRef.current) return;

        await exportWaasPrivateKey({
          walletAccount,
          displayContainer: containerRef.current,
        });
      };

      return (
        <div>
          <button onClick={handleExport}>Export private key</button>
          <div ref={containerRef} />
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

## Error Handling

* If the specified wallet account is not a WaaS WalletAccount, it will throw an `NotWaasWalletAccountError` error.

## Related functions

* [Checking WaaS Wallet Account Type](/javascript/reference/waas/checking-waas-wallet-account-type)
* [Checking if WaaS is enabled](/javascript/reference/waas/checking-if-waas-is-enabled)
* [Importing WaaS Private Key](/javascript/reference/waas/importing-waas-private-key)
* [Adding EVM Extensions](/javascript/reference/evm/adding-evm-extensions)
* [Adding Solana Extensions](/javascript/reference/solana/adding-solana-extensions)
