> ## 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.

# useUpgradeEmbeddedWallet

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

<Warning>
  This is a one-way upgrade. Once a user has upgraded to v2 and received a new v2 wallet, they will lose access to their v1 embedded wallet. We recommend that you prompt the users to confirm they do not have any funds in their wallet before making this switch.
</Warning>

### Summary

This hook can be used to upgrade v1 embedded wallet to v2 if a user has existing v1 embedded wallet.

#### Prerequisites

1. Make sure to [upgrade embedded wallet settings to v2 on your dashboard](https://app.dynamic.xyz/dashboard/embedded-wallets).
2. Make sure to [enable automatic embedded wallet creation during sign up](/react/wallets/embedded-wallets/legacy/create-embedded-wallets#during-signup-automatic).
3. (Optional) [enable creating wallets for external wallet login](/react/wallets/embedded-wallets/legacy/create-embedded-wallets#creating-wallets-for-external-wallet-login), this ensures a seamless upgrade for users with both v1 embedded wallets and third-party wallets like MetaMask. Without this option enabled, v2 wallets will not be created for these users.

#### Example

Example on a custom update wallet button

```tsx theme={"system"}
import { useUpgradeEmbeddedWallet } from '@dynamic-labs/sdk-react-core';

const UpgradeEmbeddedWalletButton = () => {
  const upgradeEmbeddedWallet = useUpgradeEmbeddedWallet();

  const onUpgradeEmbeddedWalletHandler = async () => {
        try {
            await upgradeEmbeddedWallet();
            // handle success
        } catch(e) {
            // handle error
        }
    }

  return (
    <button onClick={onUpgradeEmbeddedWalletHandler} disabled={!enabled}>
      Upgrade Embedded Wallet
    </button>
  );
};
```
