diff --git a/packages/nuxt/src/app/composables/loading-indicator.ts b/packages/nuxt/src/app/composables/loading-indicator.ts index 10f4226c6e..2003f68841 100644 --- a/packages/nuxt/src/app/composables/loading-indicator.ts +++ b/packages/nuxt/src/app/composables/loading-indicator.ts @@ -79,7 +79,9 @@ function createLoadingIndicator (opts: Partial = {}) { function clear () { clearTimeout(_throttle) - cancelAnimationFrame(rafId) + if (import.meta.client) { + cancelAnimationFrame(rafId) + } _throttle = null } @@ -93,7 +95,9 @@ function createLoadingIndicator (opts: Partial = {}) { startTimeStamp ??= timeStamp const elapsed = timeStamp - startTimeStamp progress.value = Math.max(0, Math.min(100, getProgress(duration, elapsed))) - rafId = requestAnimationFrame(step) + if (import.meta.client) { + rafId = requestAnimationFrame(step) + } } if (import.meta.client) {