Skip to main content

Use MetaMask SDK with pure JavaScript

Import MetaMask SDK into your pure JavaScript dapp to enable your users to easily connect to the MetaMask browser extension and MetaMask Mobile. The SDK for pure JavaScript has the same prerequisites as for standard JavaScript.

To import, instantiate, and use the SDK, you can insert a script in the head section of your website:

<script src=""></script>
const MMSDK = new MetaMaskSDK.MetaMaskSDK(
dappMetadata: {
name: "Example Pure JS Dapp",
url: window.location.href,
// Other options
// Because the init process of MetaMask SDK is async.
setTimeout(() => {
// You can also access via window.ethereum
const ethereum = MMSDK.getProvider();

ethereum.request({ method: 'eth_requestAccounts' });
}, 0)

You can configure the SDK using any options and call any provider API methods. Always call eth_requestAccounts using ethereum.request(args) first, since it prompts the installation or connection popup to appear.

Important SDK options


See the example pure JavaScript dapp in the JavaScript SDK GitHub repository for more information.