Architecture
MetaMask Connect manages the full connection lifecycle between your dapp and the MetaMask wallet. It detects the user's platform, selects the best transport (direct extension, QR code relay, or deeplink), creates an encrypted CAIP-25 session, and persists that session across page reloads. All relay traffic is end-to-end encrypted so the relay server never sees message content.
When a user connects, MetaMask Connect automatically handles the following:
- Platform detection: Checks for the MetaMask extension, browser type, and device.
- Transport selection: Connects directly to the extension, or falls back to a QR code or deeplink relay.
- Session creation: Establishes a CAIP-25 session for the requested chains.
- End-to-end encryption: Encrypts relay connections so the relay server never sees message content.
- Session persistence: Preserves sessions across page reloads and new tabs.
The following diagram illustrates this: