Introduction
Busly is a lightweight, framework-agnostic communication channel for real-world micro-frontends, and for any application with workflows that span several tabs or browsing contexts on the same origin.
The words "real world" matter here.
In theory, micro-frontends are about breaking a large application down into smaller parts. In practice, they're often used the other way around: to bundle several existing applications together so they look like one, even though they were never designed or built that way.
When that happens, sooner or later one of those pieces needs to talk to another. And quite often it can't, because the other piece is written in a different framework. This is the gap Busly fills.
That kind of communication is naturally expressed as events. With Busly, it looks like this. First, you define the events once, as a contract shared by both applications:
// event group definition, shared contract between applications
import { eventGroup, type } from "@busly/events";
const counterPageEvents = eventGroup({
source: "Counter Page",
events: {
set: type<number>(),
},
});Then one application, written in plain JavaScript, dispatches an event:
// application A: pure javascript
import { createDispatcher } from "@busly/js";
const dispatch = createDispatcher(counterPageEvents);
dispatch.set(42);And another application, written in Angular, listens for it:
// application B: angular
import { Component, inject } from "@angular/core";
import { AsyncPipe } from "@angular/common";
import { BusEvents } from "@busly/angular";
import { map } from "rxjs";
@Component({
imports: [AsyncPipe],
selector: "app-counter",
template: ` <p>A's Count: {{ count | async }}</p> `,
})
export class CounterComponent {
private readonly events = inject(BusEvents);
protected readonly count = this.events.on(counterPageEvents.set).pipe(map(({ payload }) => payload));
}Goals
I had a few goals in mind while building Busly:
- A small footprint. Every package is kept as small as possible, with no dependencies unless they're strictly necessary.
- A framework-agnostic, easy-to-use API. Each adapter follows its framework's own patterns, so using it feels natural, while the API stays as consistent as possible across frameworks.
- Native browser features. Busly builds on what the browser already provides and tries to use it to its full potential.
- Stability. The aim is to reach, and then keep, a stable API that can be used in production, avoiding breaking changes that would force consumers to update.
Structure
To meet these goals, Busly is split into small, focused packages. Which ones you need depends on your application:
Install only the ones you need. Each Usage guide lists the packages for its framework.