hwq c7ef3fdfe5 first | 2 years ago | |
---|---|---|
.. | ||
dist | 2 years ago | |
src | 2 years ago | |
CHANGELOG.md | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago | |
package.json | 2 years ago |
This library is used to help onboard new MetaMask users. It allows you to ask the MetaMask extension to redirect users back to your page after onboarding has finished.
This library will register the current page as having initiated onboarding, so that MetaMask knows where to redirect the user after onboarding. Note that the page will be automatically reloaded a single time once a MetaMask installation is detected, in order to facilitate this registration.
@metamask/onboarding
is made available as either a CommonJS module, and ES6 module, or an ES5 bundle.
import MetaMaskOnboarding from '@metamask/onboarding'
const MetaMaskOnboarding = require('@metamask/onboarding')
dist/metamask-onboarding.bundle.js
(this can be included directly in a page)See § Onboarding Library on the MetaMask Docs website for examples.
Assuming import MetaMaskOnboarding from '@metamask/onboarding'
, the following API is available.
MetaMaskOnboarding.isMetaMaskInstalled()
Returns true
if a MetaMask-like provider is detected, or false
otherwise. Note that we don't provide any guarantee that this is correct, as non-MetaMask wallets can disguise themselves as MetaMask.
MetaMaskOnboarding.FORWARDER_MODE
A set of constants for each of the available forwarder modes.
Constant | Description |
---|---|
INJECT |
Inject a iframe to that will refresh until MetaMask has installed |
OPEN_TAB |
Open a tab to a new page that will refresh until MetaMask has installed—this is only useful if the client app has disallowed iframes |
new MetaMaskOnboarding()
The constructor accepts an optional options bag with the following:
Option | Description |
---|---|
forwarderOrigin |
Override the forwarder URL, useful for testing. Optional, defaults to 'https://fwd.metamask.io' . |
forwarderMode |
One of the available forwarder modes. Optional, defaults to MetaMaskOnboarding.FORWARDER_MODE.INJECT . |
startOnboarding()
Starts onboarding by opening the MetaMask download page and waiting for MetaMask to be installed. Once the MetaMask extension installation is detected, a message will be sent to MetaMask to register the current site as the onboarding initiator.
stopOnboarding()
Stops onboarding registration, including removing the injected iframe
(if any).
nvm use
will automatically choose the right node version for you.yarn setup
to install dependencies and run any requried post-install scripts
yarn
/ yarn install
command directly. Use yarn setup
instead. The normal install command will skip required post-install scripts, leaving your development environment in an invalid state.Run yarn lint
to run the linter.
The project follows the same release process as the other libraries in the MetaMask organization:
main
1.x
)yarn version --minor --no-git-tag-version
)main
or 1.x
)This project is available under the MIT license.