# Wallet Lifecycle

The embedded wallet goes through several states during initialization. It's crucial to wait for the proper state before performing wallet operations.

## Embedded wallet states

| State                          | Value | Description                      |
| ------------------------------ | ----- | -------------------------------- |
| NONE                           | 0     | Initial SDK state                |
| UNAUTHENTICATED                | 1     | Before user authentication       |
| EMBEDDED\_SIGNER\_NOT\_CONFIGURED | 2     | Before wallet configuration      |
| CREATING\_ACCOUNT               | 3     | Creating new account for chainID |
| READY                          | 4     | Wallet ready for use             |

## State flow

A typical embedded wallet follows this lifecycle:

1. **NONE** — The SDK has been loaded but not yet initialized.
2. **UNAUTHENTICATED** — The SDK is initialized. The user needs to authenticate using one of the supported [authentication methods](/docs/products/embedded-wallet/authentication).
3. **EMBEDDED\_SIGNER\_NOT\_CONFIGURED** — The user is authenticated, but the embedded wallet signer has not been configured yet. This is where wallet creation or recovery happens.
4. **CREATING\_ACCOUNT** — The wallet is being created or recovered for a specific chain.
5. **READY** — The wallet is fully configured and ready for signing transactions and messages.

## Wallet creation

After authentication, the wallet needs to be configured with a [recovery method](/docs/configuration/recovery-methods). This can happen automatically (if `recoverWalletAutomaticallyAfterAuth` is enabled) or manually by calling the create/configure method in your SDK.

The wallet transitions from `EMBEDDED_SIGNER_NOT_CONFIGURED` through `CREATING_ACCOUNT` to `READY`.

## Wallet recovery

When a user logs in on a new device, the wallet needs to be recovered. The recovery method used depends on what was configured during wallet creation:

* **Automatic recovery**: Silent recovery via an encryption session from your backend
* **Password recovery**: User enters their password to recover
* **Passkey recovery**: User authenticates with their passkey (Face ID/Touch ID)

See [Recovery methods](/docs/configuration/recovery-methods) for full details on each option.

## SDK-specific state monitoring

Each SDK provides a way to observe the current wallet state:

* **React**: [`useOpenfort`](/docs/products/embedded-wallet/react/hooks/useOpenfort) hook returns the current state
* **React Native**: [`useEmbeddedEthereumWallet`](/docs/products/embedded-wallet/react-native/hooks/useEmbeddedEthereumWallet) returns `status` field
* **Swift**: [`embeddedStatePublisher`](/docs/products/embedded-wallet/swift/wallet/state) provides a reactive publisher
* **Unity**: [`GetEmbeddedState()`](/docs/products/embedded-wallet/unity/signer/state) returns the current state
* **JavaScript**: [`getEmbeddedState()`](/docs/products/embedded-wallet/javascript/use-openfort) on the Openfort instance
