qiankun README

The project's README from github.com/umijs/qiankun. As one markdown file: README.md.

qiankun logo

npm version coverage npm downloads build status license

Documentation · Quick start · Live examples · Roadmap

English · 简体中文

qiankun(乾坤)

[!WARNING]

🚧 qiankun 3.0 is currently under active development — check out the Roadmap for details. Looking for qiankun 2.x? Its documentation lives at v2.qiankun.umijs.org.

In Chinese, qian(乾) means heaven and kun(坤) earth. qiankun is the universe.

Qiankun enables you and your teams to build next-generation and enterprise-ready web applications leveraging Micro Frontends. It is inspired by and based on single-spa.

🤔 Motivation

A quick recap about the concept of Micro Frontends:

Techniques, strategies and recipes for building a modern web app with multiple teams using different JavaScript frameworks. — Micro Frontends

Qiankun was birthed internally in our group during the time web app development by distributed teams had turned to complete chaos. We faced every problem micro frontend was conceived to solve, so naturally, it became part of our solution.

The path was never easy, we stepped on every challenge there could possibly be. Just to name a few:

After solving these common problems of micro frontends and lots of polishing and testing, we extracted the minimal viable framework of our solution, and named it qiankun, as it can contain and serve anything. Not long after, it became the cornerstone of hundreds of our web applications in production, and we decided to open-source it to save you the suffering.

TLDR: Qiankun is probably the most complete micro-frontend solution you ever met🧐.

✨ Features

Qiankun inherits the fundamentals of single-spa — independent deployment, lazy loading, and a technology-agnostic host that never dictates a micro app's stack — and adds the pieces a real product needs:

🚀 Getting started

[!NOTE]

v3 ships under the rc tag while latest still points at 2.x. Install with an explicit @rc to get it.

The fastest path is the agent skill — install it, then ask your coding agent (Claude Code, Cursor, …) to scaffold a host or a micro app wired up correctly:

npx skills add umijs/qiankun

Or add qiankun to an existing host application:

npm i qiankun@rc

Load a micro app into any container element, and keep the returned handle to unmount it:

import { loadMicroApp } from 'qiankun';

const microApp = loadMicroApp({
  name: 'react-app',
  entry: '//localhost:7100',
  container: document.getElementById('subapp-container'),
});

// when this part of the page goes away:
await microApp.unmount();

If a micro app's activation is fully determined by the URL, the route-driven registerMicroApps + start APIs are the alternative orchestration model.

A micro app only has to export the three lifecycle hooks:

let root;

export async function bootstrap() {}

export async function mount(props: { container: HTMLElement }) {
  root = render(props.container);
}

export async function unmount() {
  root.unmount();
}

That is the whole contract. See the quick start for the bundler configuration each stack needs.

💿 Examples

Every example is deployed and browsable at examples.qiankunjs.com — two host shells (React and Vue) mounting the same four micro apps, each running with the JS sandbox and style isolation on, plus a standalone sandbox lab. Every app carries an "isolation lab" that demonstrates what the sandbox actually contains: globals, leaked timers, and injected styles. The shells switch between English and 简体中文, and the choice travels to the micro apps as a prop — they re-render through the update lifecycle rather than remounting.

To run them locally:

git clone https://github.com/umijs/qiankun.git
cd qiankun
pnpm install
pnpm start:example

This builds the workspace packages and starts every app in parallel — open http://localhost:7099 for the React shell or http://localhost:7105 for the Vue one. See examples/README.md for what each app demonstrates.

📦 Packages

Package Version (click for changelogs) Description
qiankun qiankun version The framework: registerMicroApps, loadMicroApp, start, prefetch
@qiankunjs/loader loader version Streaming HTML-entry loader
@qiankunjs/sandbox sandbox version JS sandbox — usable standalone
@qiankunjs/shared shared version Asset transpilers, fetch utilities, ESM-sandbox engine
@qiankunjs/single-spa single-spa version Vendored single-spa fork the framework builds on
@qiankunjs/react react version <MicroApp /> for React
@qiankunjs/vue vue version <MicroApp /> for Vue
@qiankunjs/ui-shared ui-shared version Shared internals of the UI bindings
@qiankunjs/bundler-plugin bundler-plugin version webpack 4/5 and Vite plugins for micro apps

📖 Documentation

Full documentation lives at www.qiankunjs.com (English and 简体中文):

Design decisions are recorded as RFCs under docs/rfcs.

🎯 Roadmap

qiankun 3.0 is under active development. The plan, and the discussion around it, is in the 3.0 Roadmap.

🤝 Contributing

Ask DeepWiki

Issues and pull requests are welcome. The repository is a pnpm monorepo that requires Node ^22.15 || >=24 and pnpm@11:

pnpm install         # install every workspace package
pnpm run build       # build packages and examples
pnpm run test        # unit tests (vitest, no build needed)
pnpm run test:e2e    # end-to-end tests (Playwright, against built output)
pnpm run ci          # what CI runs: build + eslint + prettier

Commits follow Conventional Commits — releases and changelogs are derived from them, so do not hand-write changesets. AGENTS.md documents the architecture, conventions and anti-patterns in depth.

👥 Contributors

Thanks to all the contributors!

contributors

🎁 Acknowledgements

📄 License

Qiankun is MIT licensed.

qiankun (umijs/qiankun)

Searching Database…

16.7K ·GitHub
这是什么?qiankun 是一个用于构建微前端应用的 JavaScript 框架,可以让独立开发、独立部署的应用(React、Vue 或其他框架)在同一个宿主页面中一起运行。
这是独立应用,还是我要加到自己项目里的框架?它是一个框架/库,需要添加到已有的宿主应用中。你需要把单独构建的微应用加载到一个容器元素中,并保留一个句柄来控制它们的生命周期。它不能单独运行。
我要怎样把 qiankun 加到项目里?先安装 npm 包(开发中的 v3 使用 @rc 标签,2.x 使用默认标签),然后调用 loadMicroApp 挂载微应用,或者使用 registerMicroApps 加 start 来按路由编排。还有一个智能体技能,可以为你生成配置正确的宿主应用或微应用脚手架。
我的微应用需要特定的打包工具吗?qiankun 提供了适用于 webpack 4/5 和 Vite 的打包插件,用于标记入口脚本并修正输出的库格式,这是微应用能够被加载所必需的。微应用本身只需要导出三个生命周期钩子(bootstrap、mount、unmount)。
qiankun 3.0 现在可以直接使用了吗?不可以——v3 仍在积极开发中,只以 npm 的 rc 标签发布,而 latest 标签仍指向较旧的 2.x 版本(其文档单独位于 v2.qiankun.umijs.org)。
除了 React 和 Vue,我还能用 qiankun 配合其他框架吗?核心加载器和沙箱与框架无关,因为微应用只需导出三个生命周期钩子;qiankun 专门提供了适用于 React 和 Vue 的现成 UI 绑定组件。
JS 沙箱究竟隔离了什么?每个微应用都运行在对 window 和 document 的 Proxy 代理视图之后,因此它的全局变量、定时器和事件监听器都保留在应用内部,并在卸载时自动清理,不会泄漏到宿主页面或其他微应用中。
为什么要做 qiankun,而不直接用 single-spa?qiankun 最初是在公司内部诞生的,用于解决 single-spa 未涵盖的问题,例如资源分发、运行时沙箱、样式隔离和资源预加载;它把这些额外的工具打包成一个基于 single-spa 构建的开源方案。
没有 Shadow DOM 的情况下,样式隔离是怎么实现的?qiankun 提供可选开启的运行时 CSS 作用域方案,基于原生 CSS 的 @scope 规则,也覆盖外部样式表,因此你无需改写 CSS,也不必承受 Shadow DOM 的性能开销。
我能否只使用沙箱,而不用整个微前端框架?可以——@qiankunjs/sandbox 包可以单独发布使用,即使不依赖 qiankun 更广泛的编排层,也能运行任何第三方脚本。
Creator
umijs
Size
38.6 MB
Stars
16.7K
Age
7y
Commits · 90 Days