All Projects → eavichay → Microfronts

eavichay / Microfronts

Licence: mit
Polyglot Front-End Solution for running multiple frameworks as one

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Labels

Projects that are alternatives of or similar to Microfronts

Bem Core
BEM Core Library
Stars: ✭ 275 (-11.86%)
Mutual labels:  frontend
Experimental React Like Framework
A new, experimental frontend for React inspired by SwiftUI. In development.
Stars: ✭ 290 (-7.05%)
Mutual labels:  frontend
Fe Advance
前端进阶十日谈
Stars: ✭ 296 (-5.13%)
Mutual labels:  frontend
Saltgui
A web interface for managing SaltStack based infrastructure.
Stars: ✭ 278 (-10.9%)
Mutual labels:  frontend
Nodebook
📖 Livre publié aux Éditions Eyrolles • Première édition : Node.js v10 et npm v6.
Stars: ✭ 286 (-8.33%)
Mutual labels:  frontend
Cli
✨ A powerful CLI for the Create Go App project. Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!
Stars: ✭ 292 (-6.41%)
Mutual labels:  frontend
Redux Orm
A small, simple and immutable ORM to manage relational data in your Redux store.
Stars: ✭ 2,922 (+836.54%)
Mutual labels:  frontend
Ilc
Isomorphic Layout Composer - complete solution for Micro Frontends composition into SPA with SSR & i18n support
Stars: ✭ 308 (-1.28%)
Mutual labels:  frontend
Snuggsi
snuggsi ツ - Easy Custom Elements in ~1kB
Stars: ✭ 288 (-7.69%)
Mutual labels:  frontend
Aofe.code
《前端架构:从入门到微前端》源码,code for Architecture of Frontend
Stars: ✭ 292 (-6.41%)
Mutual labels:  frontend
Mini.css
A minimal, responsive, style-agnostic CSS framework!
Stars: ✭ 2,938 (+841.67%)
Mutual labels:  frontend
Telegram List
List of telegram groups, channels & bots // Список интересных групп, каналов и ботов телеграма // Список чатов для программистов
Stars: ✭ 3,362 (+977.56%)
Mutual labels:  frontend
Webpack Libs Optimizations
Using a library in your webpack project? Here’s how to optimize it
Stars: ✭ 3,187 (+921.47%)
Mutual labels:  frontend
Front End Web Development Resources
This repository contains content which will be helpful in your journey as a front-end Web Developer
Stars: ✭ 3,452 (+1006.41%)
Mutual labels:  frontend
Oruga
🐛 Oruga is a lightweight library of UI components without CSS framework dependency
Stars: ✭ 297 (-4.81%)
Mutual labels:  frontend
Papercups
Open-source live customer chat
Stars: ✭ 4,554 (+1359.62%)
Mutual labels:  frontend
Translate
阿里云翻译小组,为社区输出优质的技术文章。
Stars: ✭ 293 (-6.09%)
Mutual labels:  frontend
Betterjob Of Frontend
【BJF】你有故事我有酒,我有大厂前端岗内推机会,你有简历吗?
Stars: ✭ 309 (-0.96%)
Mutual labels:  frontend
Pattern.css
CSS only library to fill empty background with beautiful patterns.
Stars: ✭ 3,481 (+1015.71%)
Mutual labels:  frontend
Localresizeimg
🔥 前端本地客户端压缩图片,兼容IOS,Android,PC、自动按需加载文件
Stars: ✭ 3,135 (+904.81%)
Mutual labels:  frontend

Microfronts

"One shell to rule them all, One shell to bind them, One shell to wrap them all and in the light to run them"

Polyglot Front-End Solution

Micro-Frontends approach enables us to split our products into separate modules as any of them is built with any web technology (i.e. React/Angular/Vue/...). A thin code layer orchestrates them as a single product, keeping the UX intact. The approach enables companies to suspend rewrites of old production code and combine new technologies with legacy ones without breaking everything.

Microfronts orchestrates multiple front-end applications with shared runtime and fully controlled sandboxing at the same time.

Creating the shell application

The shell application should be a super-thin layer of html, css and a tiny javascript file.

The shell contains the configuration for your front-ends bound with the relevant routes. The microfronts library will orchestrate the front-ends whenever route changes. It will also provide shared runtime fully accessible by demand.

Quick example:
<!-- index.html -->
<body>
  <a href="#/home">HOME (react app)</a>
  <a href="#/home">SETTINGS (angular app)</a>
  <a href="#/side-by-side">SIDE-BY-SIDE (both apps)</a>
  <iframe is="app-container" app-id="react-app"></iframe>
  <iframe is="app-container" app-id="angular-app"></iframe>
  <iframe is="app-container" app-id="error"></iframe>
  <script src="./shell.js" type="module"></script>
</body>

npm install microfronts or yarn add microfronts Microfronts should be installed in your shell application and NOT in your applications. This ensures the orchestrator remains a singleton.

// shell.js
import { Microfronts } from 'microfronts';
const application = Microfronts();
const router = application.getRouter();
const context = application.getAppContext();

const REACT_APP = {
    base: 'https://my.domain.com/app-1',
    appId: 'react-app'
};
const ANGULAR_APP = {
    base: 'https://other.domain.com/app-2',
    appId: 'angular-app'
};
const NOT_FOUND = {
    base: './404.html',
    appId: 'error'
}

router.registerRoute('*', { active: [NOT_FOUND] });
router.registerRoute('home', { active: [REACT_APP] });
router.registerRoute('settings', { active: [ANGULAR_APP] });
router.registerRoute('side-by-side', { active: [REACT_APP, ANGULAR_APP] });

router.init();

NOTE: Ensure your servers provide cross-origin access from where the shell is deployed. This can be solved on the server side or by a reverse-proxy.

To see code example, take a look at the examples folder (available in the github repo).

For type declarations you may install Microfronts and import only the interfaces.d.ts file.

Accessing the shared context

Microfronts provides a runtime-shared application context, which can be consumed by running front-ends. The context also enables the front-ends to provide utilities to other front-ends.

For example

Angular holds the user service, containing the data, login and other actions. It exposes a RxJs Subject object and would like to expose it to the rest of the world.

// angular-app/services/User.service.ts
@Injectable() class UserService {
    public stream$ = new BehaviorSubject<UserData|null>(null);
    constructor() {
        window.AppContext.set('services.stream', this.stream$);
    }
}
// react-app/components/UserStatus.js
export default () => {
    const [ user, setUserData] = useState(null);
    useEffect(() => {
        const subscription = window.AppContext.get('services.stream')
                .subscribe(data => setUserData(data)));
        return () => subscription.unsubscribe();
        }
    });
    return user
        ? <div>{user.name}, {user.lastLogin}</div>
        : <div></div>
};

This way the Angular service can be consumed at runtime within the React application. No need to rewrite or duplicate the business logic.

For asynchronous consumption, The AppContext provides the provide and require methods. The require receives a promise, fulfilled one provide is triggered with a value. This enables async dependency management across frameworks.

Adding more modules to your project

Now that the shell contains at least one front-end, more screens can be added freely. Ensure all of your internal routers use the hash-strategy (for consistency). Use the Microfronts' Router.Navigate whenever possible, though the router can watch changes from the inside.

More to come

Microfronts provides more features, such as route guards (used for dirty-clean state checking, privileges, etc.), static data per-application, messaging and more.

We need your support!

If you wish to join - open an issue, suggest an improvement, create pull-request or join the team.

Currently documentation is only inside the code, we appreciate help wiring up a good documentation webpage.

#usetheplatform

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].