Skip to main content

MetaMask JavaScript SDK options

The JavaScript version of MetaMask SDK takes several options. For example, you can specify options as follows:

const options = {
injectProvider: false,
communicationLayerPreference: 'webrtc',
};

const MMSDK = new MetaMaskSDK(options);

The following table shows the full list of options:

Option nameTypeDefault valueDescription
dappMetadata{name: "My Dapp", url: "https://mydapp.com"}undefinedOnly required for non-web dapps (for example, React Native and Unity).
injectProviderbooleantrueDoesn't inject in Node.js or React Native since the window object is unavailable.
forceInjectProviderbooleanfalseForces injection even if another provider is already present on the window object.
forceDeleteProviderbooleanfalseForces deletion of a provider that exists on a window.
checkInstallationImmediatelybooleanfalseThe SDK checks if MetaMask is installed when a call to eth_requestAccounts is made. When true, it checks before any call is made.
checkInstallationOnAllCallsbooleanfalseNormally checked when a call to eth_requestAccounts is made. When true, it checks on all calls.
shouldShimWeb3booleantrueSet as true if window.web3 should be shimmed for legacy compatibility purposes.
preferDesktopbooleanfalseFor a web dapp running on a desktop browser without a MetaMask extension, the SDK gives the option to connect with a MetaMask Mobile wallet via a QR code. When true, the SDK guides the user to install the MetaMask extension instead.
openDeeplink(deeplinkUrl: string) => voidundefinedPlatforms open deeplinks differently. For example, web: window.open versus React Native: Linking.open. This function retrieves the deeplink URL and allows developers to customize how it opens.
getUniversalLink() => stringundefinedGet the universal link that is presented on the QR Code (web) and deeplinks (mobile). This makes it easier to enable users to connect with backend code.
communicationLayerPreference"socket" or "webrtc"socketDefines the communication library that the dapp and MetaMask wallet use to communicate with each other. Waku or another similar decentralized communication layer solution coming soon.
webRTCLibWebRTC LibundefinedNot installed on the SDK by default.
WalletConnectInstanceWalletConnect LibundefinedConnect a dapp to MetaMask using WalletConnect. Not installed by default.
forceRestartWalletConnectbooleanfalseSet forceRestartWalletConnect to true to kill the previous WalletConnect session and start another one.
transports['websocket', 'polling']undefinedUsed to set the preference on socket.io transports to use.
timerBackgroundTimerundefinedUsed by React Native dapps to keep the dapp alive while using react-native-background-timer in the background
enableDebugbooleantrueEnables/disables the sending of debugging information to the socket.io server. The default is true for the beta version of the SDK. The default is false in production versions.
tip

If your project is a web dapp and injectProvider is true, then the ethereum object should be available in window.ethereum.