Skip to content

Suspense

Async Components

vue
<script lang="ts" setup>
import { defineAsyncComponent } from 'vue';

const AsyncComp = defineAsyncComponent(() => import('./AsyncComp.vue'));
</script>

<template>
  <Suspense>
    <AsyncComp />
  </Suspense>
</template>
svelte
<script lang="ts">
  const AsyncComp = import('./AsyncComp.svelte');
</script>

{#await AsyncComp then comp}
  <svelte:component this={comp.default}/>
{/await}
tsx
import { lazy, Suspense } from 'react';

const AsyncComp = lazy(() => import('./AsyncComp.tsx'));

export function App() {
  return (
    <>
      <Suspense>
        <AsyncComp />
      </Suspense>
    </>
  );
}

Released under the MIT License.