MetaMask SDK

Connects JavaScript, React, and React Native dapps to a user's MetaMask browser extension or mobile wallet.

SDK
npm
v0.34.0
336stars
Custom (Non-Commercial, ConsenSys)

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
61/100Good
Development Activity24
Maintenance52
Community84
Maturity56
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture74
Code Quality70
Innovation68
Learning Curve90

@metamask/sdk lets JavaScript, React, React Native, and Node.js applications connect directly to a user’s MetaMask wallet, whether that’s the browser extension or the mobile app reached over a QR-code relay connection. Once connected, it exposes a standard EIP-1193 ethereum provider so existing web3 code paths keep working unmodified, while the SDK itself handles environment detection, install prompts, session persistence, and reconnection across page reloads.

The project reached end-of-life in 2026: the MetaMask team deprecated the package in favor of MetaMask Connect, a rewritten SDK with direct wallet communication (no relay server) and native multichain support. New integrations should target @metamask/connect-evm or @metamask/connect-multichain instead; this package remains published for existing consumers during the migration window.

What You Get

  • Automatic environment detection that picks the right connection path (installed extension vs. QR-code relay to MetaMask Mobile vs. deep link on native)
  • A standard EIP-1193 ethereum provider so existing eth_requestAccounts/eth_sendTransaction code needs no rewrite
  • Persisted session state so a user doesn’t have to reconnect their wallet on every page load
  • Dedicated browser, Node.js, and React Native build outputs (@metamask/sdk/browser, /node, /react-native) selected automatically or explicitly
  • Batched RPC calls and an optional read-only Infura-backed provider for calls that don’t need a wallet round trip

Common Use Cases

  • Adding a “Connect Wallet” button to a web3 dapp that needs to support both desktop-extension and mobile users
  • Building a React Native or native mobile app that must deep-link into the MetaMask Mobile app for signing
  • Wiring wallet connection into a framework like Wagmi, Dynamic, or Web3-Onboard that already expects an EIP-1193 provider
  • Maintaining an existing @metamask/sdk integration during the migration window before moving to MetaMask Connect

Under The Hood

Architecture The MetaMaskSDK class in packages/sdk/src/sdk.ts (557 lines) is the facade; its constructor wires together PlatformManager (Platform/PlatfformManager.ts, environment detection), MetaMaskInstaller (install-prompt logic), RemoteConnection (services/RemoteConnection, QR/relay pairing built on the sibling @metamask/sdk-communication-layer package), and SDKProvider (provider/SDKProvider.ts, the EIP-1193-compatible object returned to callers), plus a ConnectionManager module (services/MetaMaskSDK/ConnectionManager/{connect,resume,terminate,connectAndSign,connectWith}.ts) exposing free functions bound onto the class, and an Analytics service instrumenting connection-lifecycle events. Storage is abstracted behind a common interface but split by build-time #if _REACTNATIVE compiler directives rather than runtime branching, keeping the browser bundle free of React Native code at the cost of two code paths for session persistence. Data flows one direction: a dapp call reaches a ConnectionManager function, RemoteConnection/MetaMaskInstaller negotiate the transport, and SDKProvider surfaces a stable EIP-1193 interface back to the caller regardless of which transport won.

Tech Stack Strict-mode TypeScript compiled to ES6 output, bundled with Rollup into separate CJS/ESM/UMD/React-Native builds declared via package.json’s main/module/unpkg/react-native fields. Core runtime dependencies include @metamask/providers (EIP-1193 primitives), @metamask/onboarding, eventemitter2 for the pub/sub event model, bowser for environment sniffing, cross-fetch for isomorphic HTTP, @paulmillr/qr for QR generation, and workspace-linked siblings (@metamask/sdk-communication-layer, @metamask/sdk-analytics, @metamask/sdk-install-modal-web) resolved through Yarn Berry workspaces with Turborepo task orchestration. Testing runs on Jest with a shared base config; linting is ESLint project-wide with a newer Biome config scoped to the multichain packages; Sonar and Codecov are wired into CI.

Code Quality 83 .test.ts files sit alongside their implementation files (e.g. sdk.test.ts, ConnectionManager/connect.test.ts, provider/SDKProvider.test.ts) and run under Jest, with jest.mock() used extensively to isolate the class under test from its own service dependencies — a thorough but fairly shallow-integration testing style, complemented by a separate e2e/ directory of real-environment simulator tests. TypeScript strict mode is enabled and public options (MetaMaskSDKOptions) are fully JSDoc-annotated. Naming carries some long-lived rough edges (PlatfformManager.ts, a persistent typo in an actual filename/class name), and ESLint gates every PR across three operating systems in CI.

API Design The public surface is intentionally narrow: a single default export (new MetaMaskSDK(options)), one .getProvider()-style accessor returning a familiar EIP-1193 ethereum object, and named platform-specific entry points (@metamask/sdk/browser, /node, /react-native) so consumers rarely reason about which bundle they’re getting. The common desktop-extension path is genuinely a two-line integration, and MetaMaskSDKOptions carries extensive inline documentation for IDE tooltips. React Native consumers must additionally wire an AsyncStorage module themselves, and deeper usage requires jumping out to external docs.metamask.io pages — and, as of this package’s deprecation, all further developer-experience investment is explicitly directed at MetaMask Connect instead of this SDK.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search