Someone scrolling a decentralized social feed on phone, casual couch setup, laptop with protocol dashboard nearby, evening relaxation browsing moment.
Protocols

Web3Modal SDK Integration Patterns

An implementation playbook for frontend teams embedding Web3Modal SDK into SPAs, React Native, and vanilla JS apps. Covers custom theming, multi-chain configuration, and the unified 'Connect + Sign' user flow.
introduction
Web3Modal SDK Integration Patterns

Introduction

A technical overview of embedding the Web3Modal SDK to create a unified wallet connection and signing flow across single-page, mobile, and vanilla JavaScript applications.

The Web3Modal SDK is the primary integration surface for dapps adopting the WalletConnect protocol, bundling connection, pairing, and session management into a single library. It abstracts the complexity of URI generation, deep linking, and the Sign v2 JSON-RPC session lifecycle behind a configurable UI component. For frontend teams, the SDK replaces fragmented wallet-adapter logic with a standards-compliant interface that negotiates sessions using CAIP-25 provider authorization and resolves accounts via CAIP-10 identifiers. The core operational shift is from managing individual wallet connections to handling a unified 'Connect + Sign' user flow that supports multi-chain sessions through required and optional namespace negotiation.

Integration patterns diverge significantly across React, React Native, and vanilla JS environments, each requiring distinct state management, deep-link handling, and theming approaches. A React SPA integration typically relies on the useWeb3Modal hook and Wagmi adapter, which couples the modal's lifecycle to the dapp's existing ethers or viem provider. In React Native, the integration must account for mobile deep linking via custom URL schemes or universal links, and often requires a separate @web3modal/react-native package with polyfills for crypto and Buffer. Vanilla JS implementations, common in lightweight or legacy frontends, bypass framework-specific hooks and interact directly with the Web3Modal class, demanding manual DOM management and event listener cleanup. A critical architectural decision for all patterns is whether to configure the modal with a static list of explorerRecommendedWalletIds or to rely on dynamic wallet discovery, which impacts load performance and user choice.

Operational risks include session desynchronization when a user disconnects from the wallet side without the dapp detecting the event, leading to a stale UI state. Teams must implement robust session_event listeners and periodic ping logic to maintain state accuracy. Theming and white-labeling requirements introduce a maintenance burden, as custom CSS variables or themeVariables objects must be validated against each SDK release to prevent rendering breaks. Chainscore can perform an implementation review of the Web3Modal integration, focusing on session lifecycle correctness, namespace negotiation logic, and cross-platform compatibility to ensure the connection flow is resilient, performant, and aligned with the latest WalletConnect protocol specifications.

WEB3MODAL SDK INTEGRATION

Quick Facts

Key facts for teams evaluating or implementing the Web3Modal SDK to connect wallets and manage multi-chain sessions.

FieldValueWhy it matters

Primary function

Unified UI library for connecting a dapp to a user's wallet via WalletConnect and injected providers.

Defines the user's first interaction; a poor integration leads to high bounce rates and support tickets.

Supported platforms

React, Vue, vanilla JS, React Native, and Flutter.

Determines the integration path and available UI primitives for the frontend stack.

Core dependency

Relies on the WalletConnect Sign v2 protocol for secure session establishment.

The SDK abstracts the pairing and session proposal flows; teams must still understand the underlying protocol for debugging.

Multi-chain mechanism

Uses CAIP-25 session proposals to request multiple namespaces and accounts in a single handshake.

Incorrect namespace configuration is the primary cause of 'wrong network' errors and failed transactions.

Account representation

Returns accounts as CAIP-10 identifiers (e.g., eip155:1:0x...).

Backend systems must be able to parse and validate CAIP-10 strings to manage user sessions correctly.

Theming model

Supports custom CSS variables, theme objects, and a theme mode (light/dark) to match the dapp's brand.

A mismatched theme breaks user trust; the wallet connection modal must feel like a native part of the dapp.

Migration status

WalletConnect v1 is deprecated and the bridge server is shut down. Web3Modal v3 requires Sign v2.

Any integration still using Web3Modal v2 or a legacy v1 bridge will fail to connect users.

Security boundary

The SDK facilitates a connection but does not verify message content. The dapp is responsible for verifying SIWx signatures and nonces.

A false sense of security from a 'connected' state can lead to replay attacks and session hijacking if backend verification is missing.

technical-context
EMBEDDING THE UNIFIED CONNECT + SIGN FLOW

Integration Architecture

How Web3Modal's SDK architecture abstracts WalletConnect pairing, session negotiation, and chain-agnostic identity into a single frontend integration surface.

Web3Modal SDK functions as the primary integration layer between a dapp's frontend and the WalletConnect v2 protocol suite. It abstracts the low-level pairing, session proposal, and JSON-RPC method routing into a single, themeable component. For frontend teams, the critical architectural decision is not whether to use Web3Modal, but how to configure its EIP6963 provider discovery, SIWx authentication hooks, and multi-chain namespace parameters to avoid silently degrading the user experience across different wallet implementations.

Under the hood, the SDK manages a SignClient instance that negotiates sessions conforming to CAIP-25 for multi-chain authorization and resolves accounts into CAIP-10 identifiers. When a user connects, the modal does not just return an injected provider; it orchestrates a handshake where the dapp declares required and optional namespaces (e.g., eip155:1, solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ). The wallet responds with session-scoped authorizations. A common integration pitfall is treating this as a simple 'connect wallet' button, ignoring the asynchronous session settlement and the need to handle session_update events for chain or account changes, which can lead to stale state and broken transactions.

For SPAs and React Native apps, the architecture shifts from a modal overlay to a programmatic SDK that must be tightly coupled with the app's state management. The useWeb3Modal hook provides reactive state for the active session, but teams must implement their own logic for persisting CAIP-10 identifiers as canonical user keys and mapping legacy EIP-155 chain IDs to their CAIP-2 equivalents. This mapping layer is a frequent source of bugs when dapps interact with wallets that only expose integer chain IDs, requiring a robust resolution function to prevent 'unsupported network' errors during cross-chain flows.

A security-conscious integration architecture treats the Web3Modal SDK as a boundary layer that must be configured to enforce message integrity. For high-value dapps, the integration should include out-of-band verification of the session's public key and, when using SIWx for authentication, ensure that nonce generation and signature verification happen on the backend, not in the frontend SDK. Chainscore Labs can perform an implementation review of this integration architecture, focusing on session lifecycle correctness, chain ID conflict resolution, and the security of the SIWx authentication pipeline to ensure the unified 'Connect + Sign' flow does not introduce new attack surfaces.

INTEGRATION IMPACT

Affected Teams and Systems

Frontend & dApp Teams

Web3Modal SDK integration directly impacts the user-facing connection layer. Teams must ensure the modal correctly handles multi-chain session proposals, respects required vs. optional namespaces, and gracefully degrades when a user rejects a session or switches networks.

Key actions:

  • Verify that the session_proposal handler correctly parses CAIP-25 scopes and displays them to the user without truncating chain IDs.
  • Test the unified 'Connect + Sign' flow across all supported chains to confirm that the modal does not prematurely close or leave the session in an ambiguous state.
  • Implement custom theming that maintains brand consistency while preserving the security indicators users rely on.
  • Monitor for breaking changes in Web3Modal SDK releases that may alter the React hook API or the vanilla JS instantiation pattern.

Chainscore can perform an implementation review to ensure the modal's state machine handles edge cases like offline rejection and session expiry without leaving the dapp in an inconsistent state.

implementation-impact
IMPLEMENTATION REVIEW

Key Integration Patterns

Common architectural patterns and integration points for embedding Web3Modal in SPAs, React Native, and vanilla JS environments, with a focus on multi-chain configuration and unified user flows.

01

Multi-Chain Configuration Strategy

Implement a dynamic chain configuration layer that maps CAIP-2 identifiers to Web3Modal's required and optional namespaces. Avoid hardcoding chain IDs by building a canonical registry that resolves legacy EIP-155 integers to their CAIP-2 equivalents. This prevents user-facing errors when switching networks and ensures the 'Connect + Sign' flow correctly scopes sessions across Ethereum, Solana, and other supported ecosystems. Chainscore can audit the chain resolution logic for correctness and completeness.

02

Session Lifecycle and State Management

Integrate Web3Modal's session events—session_proposal, session_update, session_delete—with your application's state management (Redux, Zustand, Context API). Handle edge cases like offline rejection, session expiry, and wallet-initiated disconnects by implementing robust fallback logic. Store the active CAIP-10 account identifier as the canonical key for user session state to prevent identity mismatches when the connected wallet changes chains. Chainscore can provide an integration review to ensure robust session handling.

03

Custom Theming and White-Labeling

Override Web3Modal's default theme variables to match your dapp's design system without forking the SDK. Use the themeVariables and themeMode options to control border radius, font family, and color palette. For React Native, ensure the themed modal respects safe area insets and platform-specific navigation gestures. Test the themed UI across wallet list views, connection prompts, and transaction confirmation screens to catch layout breaks. Chainscore can perform a UX compatibility review of the themed integration.

04

Deep Linking and Mobile Wallet Routing

Configure universal links (iOS) and app links (Android) to route Web3Modal connection requests directly into the user's preferred mobile wallet. Implement fallback strategies—such as a wallet selection list or a download page—when the target wallet is not installed. Validate deep-link URIs against a known list of wallet schemes to prevent hijacking attacks. For React Native, use Linking APIs to handle cold-start and background-to-foreground transitions reliably. Chainscore can review the deep-link flow for security vulnerabilities.

05

SIWx Authentication Integration

Replace traditional OAuth flows by binding Web3Modal's connected session to a CAIP-122 Sign-In With X (SIWx) message. After the user connects, construct a SIWx message with a server-generated nonce, request a signature via the active session, and verify it on your backend. Issue a session token with a refresh rotation tied to the wallet's disconnect event. This pattern unifies authentication across Ethereum, Solana, and other CAIP-122-compatible chains. Chainscore can audit the session lifecycle for security and standard compliance.

06

Account Abstraction (ERC-4337) Compatibility

Adapt Web3Modal's connection flow to work with smart accounts by representing the smart account's address as a CAIP-10 identifier. Configure the SDK to recognize ERC-4337 wallet providers and handle userOp signing flows instead of standard transaction signing. Ensure the modal correctly displays the smart account's deployment status and supports paymaster configuration for gasless transactions. Chainscore can review the integration for compatibility with the AA transaction lifecycle.

WEB3MODAL SDK DEPLOYMENT RISKS

Integration Risk Matrix

Operational and compatibility risks to evaluate when embedding Web3Modal in single-page applications, React Native, and vanilla JavaScript environments.

AreaWhat changesWho is affectedAction

Session negotiation

CAIP-25 handshake requires correct handling of required vs. optional namespaces

Frontend teams, wallet developers

Verify session proposal logic against the CAIP-25 specification

Chain ID resolution

Legacy EIP-155 integer IDs must map to canonical CAIP-2 identifiers

Multi-chain dapp developers

Audit chain ID mapping layer to prevent user-facing network switching errors

Account representation

User accounts are identified by CAIP-10 strings, not bare addresses

Wallet SDK teams, dapp backend engineers

Validate CAIP-10 construction and checksum logic for all supported namespaces

Mobile deep linking

Custom schemes and universal links must launch the correct wallet app

Mobile wallet and dapp developers

Review deep-link flow for hijacking vulnerabilities and implement fallback strategies

Smart account compatibility

ERC-4337 smart accounts require adapted session handling for userOp signing

Wallet SDK teams, dapp developers adopting AA

Review integration against the AA transaction lifecycle and CAIP-10 representation

Theming and UX

Custom theming can break accessibility or obscure security-critical UI elements

Frontend teams

Test themed components for contrast, readability, and clear origin display

Dependency management

SDK version bumps may introduce breaking API changes or deprecate legacy pairing

QA and DevOps teams

Pin SDK versions in CI/CD and monitor release notes for deprecation timelines

Message verification

High-security dapps must perform out-of-band session key verification

Exchange and custody provider teams

Implement and audit an out-of-band message integrity verification layer

WEB3MODAL SDK INTEGRATION

Rollout and Testing Checklist

A structured checklist for frontend teams to validate a Web3Modal SDK integration before production rollout, covering configuration, multi-chain behavior, theming, and error handling.

What to check: Confirm that a valid, non-expired projectId from the WalletConnect Cloud dashboard is used in the Web3Modal configuration and that it is not exposed in client-side repositories in a way that violates terms of service.

Why it matters: The projectId is required for relay infrastructure access. A missing or invalid ID will prevent pairing and session establishment. Leaked IDs can be abused, leading to relay rate-limiting or suspension.

Readiness signal: Successful session proposal and pairing in a staging environment using the exact build artifact intended for production.

Chains We Build On

Looking to build on a specific blockchain?

We build smart contracts, DeFi applications, wallets, tokenization platforms, and blockchain infrastructure across the major ecosystems teams choose today. That includes Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Solana, Sui, Aptos, Hedera, Stellar, and NEAR, with support for additional EVM and non-EVM networks based on your product requirements.

EVM ecosystems

  • Ethereum logo
    Ethereum
  • Arbitrum logo
    Arbitrum
  • Optimism logo
    Optimism
  • Polygon logo
    Polygon
  • Avalanche logo
    Avalanche
  • Cronos logo
    Cronos

Non-EVM ecosystems

  • Solana logo
    Solana
  • Sui logo
    Sui
  • Aptos logo
    Aptos
  • Hedera logo
    Hedera
  • Stellar logo
    Stellar
  • NEAR logo
    NEAR

Additional ecosystems

  • Polkadot logo
    Polkadot
  • Cosmos logo
    Cosmos
  • TON logo
    TON
  • Cardano logo
    Cardano
  • Algorand logo
    Algorand
  • Tempo logo
    Tempo

Also available for Base, appchains, custom EVM networks, and cross-chain product architecture.

INTEGRATION FAQ

Frequently Asked Questions

Common questions from frontend teams embedding Web3Modal in SPAs, React Native, and vanilla JS environments, covering theming, multi-chain configuration, and the unified 'Connect + Sign' user flow.

Use the defaultChain and featuredWalletIds options to guide users toward a primary network while keeping other chains accessible. Define a concise list of recommended chains in the chains array and use the tokens option to display native currency symbols. Avoid listing every supported chain; instead, let users add custom networks via the wallet interface. This reduces decision fatigue and keeps the modal focused.

Why it matters: A cluttered chain list increases drop-off. Guiding users to a primary chain while preserving flexibility improves conversion.

Readiness signal: The modal renders with a single recommended chain highlighted, and the wallet picker shows only wallets compatible with that chain.

Trusted by Industry Leaders

Delivering blockchain solutions for 5+ years.

We have partnered with 50+ leading DeFi protocols, NFT ecosystems, and fintech innovators to build secure, scalable, and capital-efficient blockchain products.

Selected Partners & Clients

ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
“I've been working with Chainscore Labs for last 3+ years, they've consistently delivered with strong ownership across multiple projects. The team is reliable and detail-oriented.”
L
Lee Erswell
CEO, Telos Foundation
how to get started

How to get started?

If you're looking for blockchain integration, ChainScore Labs has 5+ years of experience helping teams build and integrate exchanges, wallets, smart contracts, tokenization solutions, and protocol-connected products, we can help you choose the right path, integrate securely, and get to production faster. Our team consists of experienced blockchain developers and architects who can help you with your blockchain integration needs.

01

Exploration & Strategy

Define your product goals and choose the right blockchain architecture for your use case.

02

Architecture & Design

Design the smart contracts, tokenomics, and security parameters of your system.

03

Development & Integration

Build and integrate with wallets, oracles, and front-end dApps for a seamless experience.

04

Security & Launch

Comprehensive audits followed by a risk-managed mainnet deployment to protect your users.

Start a build

Need a blockchain engineering team?

Send the project context and we will respond with next steps, scope questions, and a practical path to delivery.