vue-metamask
基於 Vue 底下獲取跟檢查 Metamask 的狀態
2,586
79
| Install | |
|---|---|
npm install vue-metamask |
|
| Latest Version: | 3.0.6 |
| Vue: | 3 |
| Older releases: | 2 |
| License: | MIT |
| Last Updated: | Apr 7, 2026 |
| Links: | GitHub · npm |
Maintainer: mikecheng1208
vue-metamask

Testing Metamask's status with Vue
Demo

MetaMask will introduce an optional “Privacy Mode”, which requires that dapps ask permission to view users’ accounts. Dapps should update their code to support this feature, which will be enabled by default in the future.
Reference link
NPM Install
npm i vue-metamask -S
And then import it:
<script setup>
import { ref } from "vue";
import VueMetamask from "vue-metamask";
const msg = ref("This is demo net work");
const complete = (data) => {
console.log("GET INFO =>", data);
};
</script>
Use
<template>
<div id="demo">
<vue-metamask
userMessage="msg"
@complete="complete"
>
</vue-metamask>
</div>
</template>
How to use init connect option
<script setup>
import { ref } from "vue";
import VueMetamask from "vue-metamask";
const metamask = ref(null);
const connect = () => {
// Get ref target use init methods
metamask.value.init();
};
</script>
<template>
<div id="demo">
// close init connect
<vue-metamask ref="metamask" :init-connect="false"></vue-metamask>
// click button call Init
<button @click="connect">connect</button>
</div>
</template>
Methods
| data | type | value | Functionality |
|---|---|---|---|
| initConnect | Boolean | true (default) | Whether to connect initially |
| userMessage ( Optional ) | String | Message | return setting status message |
| complete | Event | Callback | return current data |
OnComplete return data
| key | type | value | Description |
|---|---|---|---|
| web3 | Object | function | web3 |
| metaMaskAddress | String | 0x09F38A7F... | Metamask address |
| message | String | "message" | User-defined message |
| type | String | "MAINNET" | MAINNET NO_INSTALL_METAMASK NO_LOGIN NETWORK_ERROR USER_DENIED_ACCOUNT_AUTHORIZATION |
| netID | String | 1n | User's current network id |
License
MIT.
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 3.0.6 | ^3.5.13 | MIT | |
| 3.0.5 | ^3.5.13 | MIT | |
| 3.0.4 | ^3.5.13 | MIT | |
| 3.0.3 | ^3.5.13 | MIT | |
| 3.0.2 | ^3.5.13 | MIT | |
| 2.2.1 | ^2.6.14 | MIT | |
| 2.2.0 | ^2.6.14 | MIT | |
| 2.1.0 | ^2.6.14 | MIT | |
| 2.0.3 | ^2.5.16 | MIT | |
| 2.0.2 | ^2.5.16 | MIT | |
| 2.0.1 | ^2.5.16 | MIT | |
| 2.0.0 | ^2.5.16 | MIT | |
| 1.0.10 | ^2.5.16 | MIT | |
| 1.0.9 | ^2.5.16 | MIT | |
| 1.0.8 | ^2.5.16 | MIT | |
| 1.0.7 | ^2.5.16 | MIT | |
| 1.0.6 | ^2.5.16 | MIT | |
| 1.0.5 | ^2.5.16 | MIT | |
| 1.0.4 | ^2.5.16 | MIT | |
| 1.0.3 | ^2.5.16 | MIT | |
| 1.0.2 | ^2.5.16 | MIT | |
| 1.0.1 | ^2.5.16 | MIT | |
| 1.0.0 | ^2.5.16 | MIT | |
| 0.0.9 | ^2.5.16 | MIT | |
| 0.0.8 | ^2.5.16 | MIT | |
| 0.0.7 | ^2.5.16 | MIT | |
| 0.0.6 | ^2.5.16 | MIT | |
| 0.0.5 | ^2.5.16 | MIT | |
| 0.0.4 | ^2.5.16 | MIT | |
| 0.0.3 | ^2.5.16 | MIT |
Showing the latest 30 of 32. See every release on npm