Web3js module integration for Nuxt.js - Easy and simple!
- Add
nuxt-web3
dependency to your project
yarn add nuxt-web3 # or npm install nuxt-web3
- Add
nuxt-web3
to themodules
section ofnuxt.config.js
{
modules: [
// Simple usage
"nuxt-web3",
// With options
[
"nuxt-web3",
{
/* module options */
}
]
];
}
// nuxt.config.js
export default {
modules: ["nuxt-web3"],
//....
web3: {
provider: "" // Used as fallback if no runtime config is provided
},
publicRuntimeConfig: {
web3: {
provider: process.env.WEB3_PROVIDER_URL
}
},
privateRuntimeConfig: {
web3: {
provider: process.env.PROVIDER_URL
}
}
};
If you want to use default ethereum support by browser :
window.web3 = new this.$Web3(ethereum);
//or
window.web3 = new this.$Web3(window.ethereum);
If you want to use configuration from nuxt.config.js.
window.web3 = new this.$web3;
More example usage click here
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Start development server using
npm run dev
Copyright (c) fauzan121002