Back to Nuxt

onNuxtReady

docs/4.api/3.utils/on-nuxt-ready.md

4.4.4520 B
Original Source

::important onNuxtReady only runs on the client-side. :br It is ideal for running code that should not block the initial rendering of your app. ::

ts
export default defineNuxtPlugin(() => {
  onNuxtReady(async () => {
    const myAnalyticsLibrary = await import('my-big-analytics-library')
    // do something with myAnalyticsLibrary
  })
})

It is 'safe' to run even after your app has initialized. In this case, then the code will be registered to run in the next idle callback.