These docs cover qiankun 3.0 (RC) — install it with npm i qiankun@rc. For 2.x, see the v2 docs.
Skip to content

API reference overview

The recommended way to use qiankun is to load and manage a micro-app instance on demand with loadMicroApp. It mounts the app immediately and returns a handle for updating, inspecting, and unmounting it.

ts
import { loadMicroApp } from 'qiankun';

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

// Release the instance when it is no longer needed.
await microApp.unmount();

When an app must activate automatically with the URL, use registerMicroApps with start. This is a route-driven alternative, not a prerequisite for loadMicroApp.

Public exports

ExportPurpose
loadMicroAppLoad and mount one micro-app immediately, returning a MicroApp handle.
registerMicroAppsRegister micro-apps driven by URL activeRule values.
startStart route-driven registration mode. You normally do not call it when using loadMicroApp directly.
setDefaultMountAppNavigate to a default app route when no app is mounted.
runAfterFirstMountedRun a callback once after the first micro-app mounts.
addErrorHandler / removeErrorHandlerAdd or remove a global error handler.
isRuntimeCompatibleProbe whether the browser supports the qiankun v3 base runtime.
prefetchAppsDeprecated manual prefetch API.

Two loading modes

On demand: loadMicroApp

Use it for page regions, components, modals, and apps controlled by host state. The host decides when to create and unmount each instance.

ts
function loadMicroApp<T extends ObjectType>(
  app: LoadableApp<T>,
  configuration?: AppConfiguration,
  lifeCycles?: LifeCycles<T>,
): MicroApp;

The returned handle exposes mount, unmount, getStatus, and lifecycle promises. It exposes update only when the micro-app exports that optional lifecycle. Call unmount() for every instance you no longer use.

Route driven: registerMicroApps + start

Use this mode when the URL completely determines whether an app is mounted. Register the applications and their activeRule values, then call start() so single-spa can activate and unmount them automatically.

ts
registerMicroApps(apps, lifeCycles?);
start(opts?);

See Loading a micro-app instance for help choosing between the two modes.

Configuration, lifecycles, and types

Migration and deprecations

Use the migration guide as the single source of truth when upgrading from qiankun 2.x. Individual API pages describe only current behavior.

prefetchApps is deprecated. Streaming HTML Entry loading discovers and preloads resources while parsing an entry. See Optimize loading for current guidance.

Released under the MIT License.