Neon Labs
Published in

Neon Labs

Integrating MetaMask with Your Neon dApp

MetaMask is one of the most popular cryptocurrency wallets, and it being a browser extension makes it the standard choice for users to connect with Web3 apps. MetaMask integration is therefore critical to opening up your Neon dApp to the widest possible market, and its easy-to-use interface makes it great for onboarding those who are new to crypto.

The days of manually entering a custom network configuration to your wallet are over — integrating MetaMask is a major step in making your dApp user experience the smoothest it can be! In this article, we will walk you through how you can do just that.

Installation and Prerequisites

Before you can begin, you must have a JavaScript project set up, and it is highly recommended to have the MetaMask browser extension installed in order to test the integration locally. It is also recommended that you install MetaMask’s ‘detect-provider’ package, to help with detecting the provider of the MetaMask extension. This package can be installed as follows:

Adding a ‘Connect Wallet’ Button

For our example, let’s use the most common use case for MetaMask integration — a simple “Connect Wallet” button. This button, common on many Web3 application sites, allows the site to display or interact with on-chain data, available via your wallet.

A simple HTML button can be created like so:

Now, we can walk through the JavaScript script that will make this button work. First, we have to check if the provider is MetaMask.

If it is, we request to connect to the wallet’s Ethereum accounts.

Now we send another request, this time to add the Neon blockchain to MetaMask. We also need to make sure that any error is caught, if one occurs.

Finally, in case the provider was not MetaMask, send a console error message with the text “Please install MetaMask”.

This code, taken together, should give you a button that connects the user’s MetaMask wallet to Neon and walks them through the steps to do so. The connection process, from a user’s perspective, will look more or less as shown in the following screenshots:

Clicking the button will prompt MetaMask to ask permission to connect to your code. Click ‘Next’ to continue
Click ‘Connect’
MetaMask will now ask for permission to add the Neon Devnet to your wallet. Click ‘Approve’
Finally, MetaMask will ask permission to switch to the Neon Devnet from the previous network you were on (in this case, Ethereum). Click ‘Switch Network’.


Integrating MetaMask into your Neon project is a breeze when you follow these simple instructions. MetaMask’s popularity and browser integration make it an excellent choice for growing your dApp’s user base. It is now up to you, the dApp developer, to harness the powerful synergy between Neon and MetaMask and make something beautiful.

For more information on the Neon EVM and how to use it to build your next project, take a look at the Neon docs. If you’re feeling stuck, feel free to contact the Neon team on our Discord server and ask any questions you like — and if you find a bug, be sure to report it to the neon-support repo on GitHub!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store