@@ -74,15 +74,17 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
7474 const compactNumberFormatter = useCompactNumberFormatter ( )
7575 const bytesFormatter = useBytesFormatter ( )
7676 const packages = computed ( ( ) => toValue ( packageNames ) )
77-
78- const ready = shallowRef ( false )
77+ const nuxt = useNuxtApp ( )
7978
8079 // Cache of fetched data by package name (source of truth)
8180 const cache = shallowRef ( new Map < string , PackageComparisonData > ( ) )
8281
8382 // Derived array in current package order
8483 const packagesData = computed (
85- ( ) => ready . value && packages . value . map ( name => cache . value . get ( name ) ?? null ) ,
84+ ( ) =>
85+ import . meta. client &&
86+ ! nuxt . isHydrating &&
87+ packages . value . map ( name => cache . value . get ( name ) ?? null ) ,
8688 )
8789
8890 const status = shallowRef < 'idle' | 'pending' | 'success' | 'error' > ( 'idle' )
@@ -253,22 +255,21 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
253255
254256 // Watch for package changes and refetch (client-side only)
255257 if ( import . meta. client ) {
256- useNuxtApp ( ) . hook ( 'app:suspense:resolve' , ( ) => {
257- ready . value = true
258- watch (
259- packages ,
260- newPackages => {
258+ watch (
259+ ( ) => [ nuxt . isHydrating , packages . value ] as const ,
260+ ( [ isHydrating , newPackages ] ) => {
261+ if ( ! isHydrating ) {
261262 fetchPackages ( newPackages )
262- } ,
263- { immediate : true } ,
264- )
265- } )
263+ }
264+ } ,
265+ { immediate : true } ,
266+ )
266267 }
267268
268269 // Compute values for each facet
269270 function getFacetValues ( facet : ComparisonFacet ) : ( FacetValue | null ) [ ] {
270271 // If not ready or no data, return array of nulls to render skeletons
271- if ( ! ready . value || ! packagesData . value || packagesData . value . length === 0 ) {
272+ if ( ! packagesData . value || packagesData . value . length === 0 ) {
272273 return Array . from ( { length : packages . value . length } , ( ) => null )
273274 }
274275
0 commit comments