MCPcopy
hub / github.com/nuxt/nuxt / setup

Function setup

packages/nuxt/src/components/runtime/lazy-hydrated-component.ts:10–28  ·  view source on GitHub ↗
(props, ctx)

Source from the content-addressed store, hash-verified

8 props,
9 emits: ['hydrated'],
10 setup (props, ctx) {
11 if (import.meta.server) {
12 const nuxtApp = useNuxtApp()
13 nuxtApp.hook('app:rendered', ({ ssrContext }) => {
14 // track lazy hydrated components so prefetch/preload tags are not rendered for them
15 // but keep them in modules so CSS links are still rendered
16 ssrContext!['~lazyHydratedModules'] ||= new Set()
17 ssrContext!['~lazyHydratedModules'].add(id)
18 })
19 }
20 // wrap the async component in a second component to avoid loading the chunk too soon
21 const child = defineAsyncComponent({ loader })
22 const comp = defineAsyncComponent({
23 hydrate: defineStrategy(props as ExtractPropTypes<P>),
24 loader: () => Promise.resolve(child),
25 })
26 const onVnodeMounted = () => { ctx.emit('hydrated') }
27 return () => h(comp, mergeProps(ctx.attrs, { onVnodeMounted }), ctx.slots)
28 },
29 })
30}
31

Callers

nothing calls this directly

Calls 2

useNuxtAppFunction · 0.90
resolveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…