qiankun
它能做什么
这个技能说明如何使用 qiankun 构建主应用,以及在运行时加载到主应用中的较小子应用。适合希望将大型前端拆分为多个部分的网页开发者。
适用场景
- ✓当你想创建一个主应用,用来加载多个独立的前端应用时。
- ✓当你想把现有的 Vite 应用改造为微子应用时。
- ✓当你使用 React 或 Vue 设置微前端加载时。
技能链接
https://github.com/umijs/qiankun/blob/next/skills/qiankun/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我把现有的 Vite React 应用改造成一个 qiankun 子应用,让主应用外壳可以加载它。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会阅读与任务相符的指南,然后按照主应用或子应用的步骤操作。它会使用固定端口和匹配的应用名称,让各部分之间能够相互找到。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
qiankun
qiankun is a micro-frontend framework: a main (host) app loads sub (micro) apps from their HTML entries at runtime, each inside a JS sandbox, with opt-in CSS isolation. This skill is the agent-facing manual for qiankun 3.x.
Task routing
Read only the reference file(s) the task at hand needs:
| Task | Read |
|---|---|
| Create a micro (sub) app, or convert an existing Vite app | references/create-micro-app.md |
| Create a main (host) app | references/create-main-app.md |
| Anything else — migration, style isolation, sandbox, debugging | https://qiankun.umijs.org and examples/ in https://github.com/umijs/qiankun |
Before you start
Determine these, asking the user only when not inferable from context:
- App type — main (host/shell) or sub (micro app).
- App name — lowercase letters, numbers, hyphens. The name the host registers must exactly match the name the sub app uses in its classic-mode fallback.
- Framework — React or Vue; TypeScript or JavaScript. Templates in the references are TS; strip types for JS.
- Dev port — must be fixed and unique per app, because the host hard-references it in
entry. Convention: main app7099, sub apps7101,7102, …
Package versions — until qiankun 3.0 stable ships, rc is the dist-tag for the core packages:
| Package | Dist-tag | Goes in |
|---|---|---|
qiankun |
rc |
main app dependencies |
@qiankunjs/react / @qiankunjs/vue |
rc |
main app dependencies (optional UI binding) |
@qiankunjs/bundler-plugin |
rc |
sub app devDependencies |
Key facts
These invariants shape every task below:
- Vite sub apps need no dedicated build mode. qiankun 3 loads
<script type="module">natively through its ESM sandbox — regularvite dev/vite buildoutput is qiankun-ready as-is. - The JS sandbox is on by default. CSS isolation is opt-in per app via
styleIsolation: true(runtime CSS@scope). - A sub app must stay runnable standalone: when not loaded by qiankun (
window.__POWERED_BY_QIANKUN__is undefined) it renders itself directly. - Always unmount what you mount.
loadMicroAppreturns a handle whose.unmount()must be called when the app leaves; theMicroAppcomponent bindings do this automatically on component unmount. Unmounted instances stay cached for reuse by app name; only.unload()/unloadMicroApp(name)releases them, and the bindings never call those. - Webpack sub apps use
@qiankunjs/bundler-plugin/webpackinstead of the Vite plugin; see the docs.
After any creation task
Verify the result following the checklist at the end of the reference you used. If a browser tool is available, perform the checks yourself instead of asking the user to.
常见问题
它涵盖哪个版本?
它是 qiankun 3.x 的手册,并说明在 3.0 正式版发布之前,部分核心包使用 rc 标签。
它同时支持 Vue 和 React 吗?
支持。该技能同时涵盖 React 和 Vue,其模板使用 TypeScript 编写。
迁移或调试怎么办?
对于创建主应用和子应用之外的主题,该技能会指向 qiankun 官方网站和示例。
详情
作者的原始描述
Usage manual for building micro-frontend projects with qiankun 3.x. Use when the user wants to create a qiankun main (host) app or sub (micro) app, convert an existing Vite app into a qiankun micro app, or wire up micro-frontend loading with React/Vue.
repo: umijs/qiankun
热度
- GitHub 星标
- 17k
- 排名
- #10799
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …