This document is maintained at Please submit issues at that repository.


Muon.js takes Muon Node and adds a websockets based transport and discovery. These connect to the MuonJS Gateway service.

This enables Muon to run within the browser and interact with back end services with the full set of protocols available to server side microservices.

In order to use Muon in the browser, you therefore need to :-

  • Set up the MuonJS gateway, connected to the target Muon network. See MuonJS Gateway for more information

  • Import muon.js into your browser context (either directly, or more likely using npm with webpack or similar)

  • Instantiate a Muon object in your browser, which fronts a websocket connection to the gateway.

The rest of this document assumes you have a running MuonJS Gateway


Broadly, there are two options for integrating MuonJS into your browser code.

  • Directly linking via a script tag

  • Install via NPM and incorporate via a javascript packer.

We recommend using a full build system.

Install via NPM

npm install muon-core

With this installed, you then need to have some form of front end build system in place.

You can use the new Molecule project as an example.

Once you have muon available in your browser context, you need to instantiate and use it.

var Muon = require("muonjs")          (1)
var muon = Muon.client({port: 9898})  (2)

muon.replay("my-stream", {"stream-type": "hot"}, (event) => { (3)
}, (error) => {
    console.log("Disconnected from event store", error)
}, (complete) => {
    console.log("Stream completed (except that it's hot, so this will never execute...")
1 Import MuonJS using require.js provided by webpack etc.
2 Instantiate a MuonJS client, connecting to the origin server on the default port 9898
3 Begin an event replay. This will connect to the photon service in the back end system.

Once you have this working, MuonJS is the same code as Muon Node, and so will work the same.