Skip to content

Instantly share code, notes, and snippets.

@joeldenning
Last active October 5, 2018 22:11
Show Gist options
  • Save joeldenning/d72c28eb395665849b5fd311f33272f2 to your computer and use it in GitHub Desktop.
Save joeldenning/d72c28eb395665849b5fd311f33272f2 to your computer and use it in GitHub Desktop.
A simple root-application.js file for single-spa
import {declareChildApplication, start} from 'single-spa';
// Register your first application with single-spa. More apps will be registered as you create them
declareChildApplication("cool-app", loadCoolApp, isCoolAppActive);
// Tell single-spa that you're ready for it to mount your application to the DOM
start();
// This is a "loading function"
function loadCoolApp() {
return import("./cool-app/cool.app.js");
}
// This is an "activity function"
function isCoolAppActive() {
return window.location.hash.startsWith("#/cool");
}
@dvnrsn
Copy link

dvnrsn commented Oct 5, 2018

Your medium article that references this is almost two years old, but it still stands as one of the best annotated guides. Consider updating declareChildApplication to registerApplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment