Nuxt/docs/3.api/3.utils/on-nuxt-ready.md
Sébastien Chopin f26a801775
docs: update to new website (#23743)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
2023-10-18 12:59:43 +02:00

813 B

title description links
onNuxtReady The onNuxtReady composable allows running a callback after your app has finished initializing.
label icon to size
Source i-simple-icons-github https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/ready.ts xs

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

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.