SmallRuralDog / web3modal-vue

A single Web3 / Ethereum provider solution for all Wallets
https://smallruraldog.github.io/web3modal-vue/
MIT License
109 stars 68 forks source link

i am using nuxt and i'm getting this window is not defined #12

Open Johnnyevans32 opened 2 years ago

Johnnyevans32 commented 2 years ago

`


>  ERROR  [Vue warn]: Error in created hook: "ReferenceError: window is not defined"

found in

---> <Web3ModalVue> at node_modules/web3modal-vue/src/Web3ModalVue.vue
       <VsNavbar>
         <NavBar> at components/NavBar.vue
           <HomePage> at pages/index.vue
             <Nuxt>
               <DefaultLayout> at layouts/default.vue
                 <Root>

`

Johnnyevans32 commented 2 years ago

more ref to the issue

serdartepeyurt commented 2 years ago

The issue raises from ssr render cycle, since ssr mode doesnt have any window object. You need to wrap your code into a block something like

if(window){
...
}

and you will be fine.

GZ2829 commented 2 years ago

you need to wrap the web3modalvue in client-only or no-ssr tags