Skip to content

Pitfalls ​

The embedded wallet works like an extension wallet in most ways. These are the places where it doesn't, and where integrations most often go wrong.

Setup ​

  • Call createWallet once, at the top level. It creates the wallet iframe. A second call logs a warning and returns the first wallet, ignoring the new options.
  • It does nothing on the server. Outside the browser, createWallet returns a stand-in: getProvider resolves to null and every other method throws. With server-side rendering, use the wallet only in code that runs in the browser, such as effects and event handlers.
  • Keep <WalletWidget> mounted. It renders nothing until the user connects. Put it at the root, next to your app, not inside a page that unmounts.
  • Register an App ID before you ship. Without one, the wallet only loads on localhost. See App ID.

Connecting ​

  • Call connect() inside a click handler. It opens the signer in a popup, and browsers block popups that don't come from a user gesture.
  • Read the address silently. solana.connect({ onlyIfTrusted: true }) never opens the signer: it returns the key when your app is trusted and the wallet is unlocked, and throws otherwise. <WalletProvider> runs it once on mount. On EVM chains, eth_accounts reads the address the same way.
  • useConnected() doesn't mean you have a key. It can turn true before the provider holds a public key. Gate signing on the address connect() returned.
  • Read every address you need before you create the user. If your backend stores both the Solana and the EVM address, wait for both reads. Acting on the first one creates an account without the other.

Locks and accounts ​

  • A lock fires disconnect. The wallet locks itself when idle. Don't treat that as a sign-out.
  • Unlocking doesn't reconnect. useConnected() turns true again, but the provider has no key until you call connect({ onlyIfTrusted: true }) again.
  • There is no account-switch event. Store the address your backend session was signed for, and compare it on every load. See Signing in to your backend.

Solana transactions ​

  • The wallet signs but doesn't send. Send the signed bytes through your own RPC.
  • Fetch the blockhash last. It lasts about 30 seconds, and the user needs most of that to approve.
  • v1 transactions need their limits set. Their compute unit and account data limits default to zero. See Transaction versions.