mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
f26a801775
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
26 lines
813 B
Markdown
26 lines
813 B
Markdown
---
|
|
title: "onNuxtReady"
|
|
description: The onNuxtReady composable allows running a callback after your app has finished initializing.
|
|
links:
|
|
- label: Source
|
|
icon: i-simple-icons-github
|
|
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/ready.ts
|
|
size: 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.
|
|
::
|
|
|
|
```ts [plugins/ready.client.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.
|