Back
VueMediumNew
What is `Suspense` used for in Vue 3?
Coordinating async dependencies during rendering
Ideal Answer
<Suspense> is a built-in component for orchestrating async dependencies in a component tree — for example, components using async setup() or async components loaded with defineAsyncComponent. It lets you render a fallback (like a loading spinner) while the async content resolves.
JavaScript
<Suspense>
<template #default>
<AsyncDashboard />
</template>
<template #fallback>
<LoadingSpinner />
</template>
</Suspense>
As of recent Vue versions, Suspense is still considered an experimental feature and its API may change in the future, so it's worth checking the current docs before relying on it heavily in production.