For Vue Router, use () => import('./views/Page.vue') directly in route definitions.
Details
Async components in Vue 3 use defineAsyncComponent to wrap a dynamic import(). The bundler splits the component into a separate chunk that is loaded only when the component is first rendered. This reduces the initial JavaScript payload.
Trade-offs:
Loading delay — users see a spinner or blank space while the component loads
Error handling is required — network failures must be caught and displayed gracefully
Too many async components can cause a "waterfall" of sequential network requests
SSR requires special handling — the server must await all async components before sending HTML
When NOT to use:
For small, frequently used components — the overhead of a separate chunk is not worth it
For above-the-fold content that must render immediately
When the component is always needed — static import is simpler
Read the instructions and examples in this document.
Apply the patterns to your implementation, adapting to your specific context.
Verify your implementation against the details and edge cases listed above.
Harness Integration
Type: knowledge — this skill is a reference document, not a procedural workflow.
No tools or state — consumed as context by other skills and agents.
Success Criteria
The patterns described in this document are applied correctly in the implementation.
Edge cases and anti-patterns listed in this document are avoided.
1---2name: vue-async-components3description: Vue Async Components4---5# Vue Async Components67> Load Vue components lazily to reduce initial bundle size using defineAsyncComponent89## When to Use1011- A component is heavy (charts, editors, maps) and not needed on initial render12- Implementing route-based code splitting in a Vue Router application13- Conditionally loading components behind feature flags or user interactions1415## Instructions16171. Use `defineAsyncComponent(() => import('./HeavyComponent.vue'))` to lazy-load.182. Provide `loadingComponent` and `errorComponent` options for UX during loading.193. Set a `delay` (ms) before showing the loading component to avoid flicker.204. Wrap async components in `<Suspense>` for coordinated loading states.2122```typescript23import { defineAsyncComponent } from 'vue';2425const AsyncChart = defineAsyncComponent({26 loader: () => import('./Chart.vue'),27 loadingComponent: LoadingSpinner,28 errorComponent: ErrorDisplay,29 delay: 200,30 timeout: 10000,31});32```33345. For Vue Router, use `() => import('./views/Page.vue')` directly in route definitions.3536## Details3738Async components in Vue 3 use `defineAsyncComponent` to wrap a dynamic `import()`. The bundler splits the component into a separate chunk that is loaded only when the component is first rendered. This reduces the initial JavaScript payload.3940**Trade-offs:**4142- Loading delay — users see a spinner or blank space while the component loads43- Error handling is required — network failures must be caught and displayed gracefully44- Too many async components can cause a "waterfall" of sequential network requests45- SSR requires special handling — the server must await all async components before sending HTML4647**When NOT to use:**4849- For small, frequently used components — the overhead of a separate chunk is not worth it50- For above-the-fold content that must render immediately51- When the component is always needed — static import is simpler5253## Source5455https://patterns.dev/vue/async-components5657## Process58591. Read the instructions and examples in this document.602. Apply the patterns to your implementation, adapting to your specific context.613. Verify your implementation against the details and edge cases listed above.6263## Harness Integration6465- **Type:** knowledge — this skill is a reference document, not a procedural workflow.66- **No tools or state** — consumed as context by other skills and agents.6768## Success Criteria6970- The patterns described in this document are applied correctly in the implementation.71- Edge cases and anti-patterns listed in this document are avoided.
Run npx skillmds@latest add intense-visions/vue-async-components in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Vue Async Components It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Intense-Visions (@intense-visions) published this skill. Their other Agent Skills are listed on their SkillMD profile.