JavaScript SDK options
The JavaScript version of MetaMask SDK takes the following options.
checkInstallationImmediately
- Syntax
 - Example
 
checkInstallationImmediately: <boolean>
checkInstallationImmediately: true
Enables or disables immediately checking if MetaMask is installed on the user's browser.
If true, the SDK checks for installation upon page load and sends a connection request, prompting
the user to install MetaMask if it's not already installed.
If false, the SDK waits for the connect method to be called to check for installation.
The default is false.
checkInstallationOnAllCalls
- Syntax
 - Example
 
checkInstallationOnAllCalls: <boolean>
checkInstallationOnAllCalls: true
Enables or disables checking if MetaMask is installed on the user's browser before each RPC request.
The default is false.
communicationServerUrl
- Syntax
 - Example
 
communicationServerUrl: <string>
communicationServerUrl: "https://metamask-sdk-socket.metafi.codefi.network/"
The URL of the communication server to use. This option is mainly used for debugging and testing the SDK.
dappMetadata
- Syntax
 - Example
 
dappMetadata: {
  name: <string>,
  url: <string>,
  iconUrl: <string>,
}
dappMetadata: {
  name: "My Dapp",
  url: "https://mydapp.com",
  iconUrl: "https://mydapp.com/icon.png",
}
Metadata about the dapp using the SDK. The metadata options are:
name- Name of the dappurl- URL of the dappiconUrl- URL of the dapp's icon
Setting dappMetaData creates a clear and trustworthy user experience when connecting your dapp to
MetaMask Mobile.
MetaMask Mobile displays this metadata in the connection modal to help users identify and verify the
connection request.
defaultReadOnlyChainId
- Syntax
 - Example
 
defaultReadOnlyChainId: <number or hexadecimal string>
defaultReadOnlyChainId: "0x1"
Enables sending read-only RPC requests to this chain ID before the user connects to MetaMask. The value is automatically updated to the chain ID used in MetaMask once connected.
enableAnalytics
- Syntax
 - Example
 
enableAnalytics: <boolean>
enableAnalytics: true
Enables or disables sending anonymous analytics to MetaMask to help improve the SDK.
The default is true.
extensionOnly
- Syntax
 - Example
 
extensionOnly: <boolean>
extensionOnly: true
Enables or disables automatically using the MetaMask browser extension if it's detected.
The default is true.
infuraAPIKey
- Syntax
 - Example
 
infuraAPIKey: <string>
infuraAPIKey: process.env.INFURA_API_KEY
The Infura API key to use for RPC requests. Configure this option to make read-only RPC requests from your dapp.
Use Infura allowlists to protect against other people submitting requests to your API key. You can restrict interactions to specific addresses, origins, user agents, and request methods. We recommend using all allowlist options to maximize the security of your API key and dapp.
headless
- Syntax
 - Example
 
headless: <boolean>
headless: true
Enables or disables headless mode.
Setting this to true allows you to display custom modals.
The default is false.
openDeeplink
- Syntax
 - Example
 
openDeeplink: <function>
openDeeplink: (link: string) => {
  if (canOpenLink) {
    Linking.openURL(link);
  }
}
A function that is called to open a deeplink to the MetaMask Mobile app.
readonlyRPCMap
- Syntax
 - Example
 
readonlyRPCMap: <map>
readonlyRPCMap: {
  "0x539": "http://localhost:8545",
}
A map of RPC URLs to use for read-only RPC requests.
shouldShimWeb3
- Syntax
 - Example
 
shouldShimWeb3: <boolean>
shouldShimWeb3: false
Enables or disables shimming the window.web3 object with the Ethereum provider returned by the SDK
(useful for compatibility with older browsers).
The default is true.