Skip to content

QiankunMicro-Frontend Solution

Probably the most complete micro-frontends solution you ever met🧐

Qiankun

📦 Installation

bash
npm install qiankun
bash
yarn add qiankun
bash
pnpm add qiankun

🔨 Quick Start

Main Application

typescript
import { registerMicroApps, start } from 'qiankun';

// register micro apps
registerMicroApps([
  {
    name: 'reactApp',
    entry: '//localhost:7100',
    container: '#yourContainer',
    activeRule: '/yourActiveRule',
  },
  {
    name: 'vueApp',
    entry: { scripts: ['//localhost:7100/main.js'] },
    container: '#yourContainer2',
    activeRule: '/yourActiveRule2',
  },
]);

// start qiankun
start();

Micro Application

typescript
/**
 * bootstrap will only be called once when the micro application is initialized
 * mount will be called every time the micro application enters
 * unmount will be called every time the micro application leaves
 */
export async function bootstrap() {
  console.log('react app bootstraped');
}

export async function mount(props) {
  ReactDOM.render(<App />, props.container ? props.container.querySelector('#root') : document.getElementById('root'));
}

export async function unmount(props) {
  ReactDOM.unmountComponentAtNode(
    props.container ? props.container.querySelector('#root') : document.getElementById('root'),
  );
}

🌟 Why qiankun?

🎯 Zero Intrusion

Almost no intrusion to existing applications, only need to expose necessary lifecycle functions

📱 All Scenarios

Supports both route-based and manual loading of micro applications

🔒 Secure Isolation

Complete sandbox solution with JS isolation and CSS isolation

⚡ High Performance

Supports preloading, caching and other performance optimization solutions

👥 Community

GitHub DiscussionsDingTalk GroupWeChat Group
qiankun discussionsDingTalk Group QR Codeview group QR code

Released under the MIT License.