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

# useUpgradeToDynamicWaasFlow

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

> Hook for prompting users to upgrade to Dynamic's MPC v3 wallets with Wallet-as-a-Service (WaaS) functionality

### Summary

The `useUpgradeToDynamicWaasFlow` hook provides a programmatic way to prompt users to upgrade their existing wallets to Dynamic's advanced MPC v3 wallets with Wallet-as-a-Service (WaaS) functionality. This hook opens the upgrade flow modal and navigates users through the process of migrating to enhanced wallet capabilities.

The hook needs to be initialized within a child of [DynamicContextProvider](/react/reference/providers/dynamiccontextprovider).

### Usage

Available functions:

| Method                         | Type         | Description                                                     |
| ------------------------------ | :----------- | :-------------------------------------------------------------- |
| promptUpgradeToDynamicWaasFlow | `() => void` | Opens the upgrade flow modal to migrate to Dynamic WaaS wallets |

### Return Value

The hook returns an object with the following property:

* `promptUpgradeToDynamicWaasFlow`: A function that when called, opens the auth flow modal and navigates to the WaaS upgrade view

### What is WaaS Upgrade?

Dynamic's Wallet-as-a-Service (WaaS) upgrade allows users to migrate from standard wallets to advanced MPC v3 wallets that provide:

* Enhanced security with multi-party computation (MPC)
* Advanced key management capabilities
* Improved backup and recovery options
* Enterprise-grade wallet infrastructure

### Example

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

const UpgradeWalletButton = () => {
  const { promptUpgradeToDynamicWaasFlow } = useUpgradeToDynamicWaasFlow();

  return (
    <button
      onClick={() => promptUpgradeToDynamicWaasFlow()}
      className="upgrade-btn"
    >
      Upgrade to Advanced Wallet
    </button>
  );
};
```

### Advanced Example with User State Check

```typescript theme={"system"} theme={"system"}
import { useUpgradeToDynamicWaasFlow, useDynamicContext } from '@dynamic-labs/sdk-react-core';

const ConditionalUpgradeComponent = () => {
  const { promptUpgradeToDynamicWaasFlow } = useUpgradeToDynamicWaasFlow();
  const { user, primaryWallet } = useDynamicContext();

  // Check if user is eligible for upgrade
  const isEligibleForUpgrade = user && primaryWallet && primaryWallet.key !== 'dynamicwaas';

  const handleUpgrade = () => {
    if (isEligibleForUpgrade) {
      promptUpgradeToDynamicWaasFlow();
    }
  };

  if (!isEligibleForUpgrade) {
    return null; // Don't show upgrade option if not eligible
  }

  return (
    <div className="upgrade-container">
      <h3>Upgrade Your Wallet</h3>
      <p>Get enhanced security and features with Dynamic WaaS</p>
      <button onClick={handleUpgrade}>
        Start Upgrade Process
      </button>
    </div>
  );
};
```

### Error Handling

The hook will throw errors in the following scenarios:

* **Missing context**: If used outside of `DynamicContextProvider`
* **Context method failures**: If internal context methods (`setShowAuthFlow` or `pushView`) fail

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

const SafeUpgradeComponent = () => {
  const { promptUpgradeToDynamicWaasFlow } = useUpgradeToDynamicWaasFlow();

  const handleUpgrade = async () => {
    try {
      promptUpgradeToDynamicWaasFlow();
    } catch (error) {
      console.error('Failed to start upgrade flow:', error);
      // Handle error appropriately (show user message, retry logic, etc.)
    }
  };

  return (
    <button onClick={handleUpgrade}>
      Upgrade Wallet
    </button>
  );
};
```
