Nuxt.js: 'loaded' event on client side

Created on 25 Jul 2017  路  8Comments  路  Source: nuxt/nuxt.js

Hi,
I'm wondering if Nuxt.js provides the ability to notify the client that Nuxt has setup properly.
The equivalent to to jQuery might be

$( document ).ready()

The use case is that I may have some code depending on window.$Nuxt, and a in-house mechanism for detect if it's ready would be great, for example, a simple event would do:

var e = new CustomEvent('nuxt-loaded')
window. dispatchEvent(e)

Most helpful comment

Hi. You can use window.onNuxtReady helper.

if (process.browser) {
  window.onNuxtReady((app) => {
    console.log('Nuxt ready!')
  })
}

All 8 comments

Hi. You can use window.onNuxtReady helper.

if (process.browser) {
  window.onNuxtReady((app) => {
    console.log('Nuxt ready!')
  })
}

@pi0 Thanks! It solves my problem.
Although using native API might be a better choice as there may be codes importing from

Related issues

gary149 picture gary149  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

surmon-china picture surmon-china  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

mikekidder picture mikekidder  路  3Comments