Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

single-spa

Package Overview
Dependencies
Maintainers
0
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

single-spa

The router for easy microfrontends

  • 6.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
238K
decreased by-0.46%
Maintainers
0
Weekly downloads
 
Created

What is single-spa?

single-spa is a JavaScript framework for front-end microservices. It allows you to build and manage multiple microfrontends that can coexist and interoperate within a single web application. This enables teams to work independently on different parts of a web application, using different frameworks if necessary.

What are single-spa's main functionalities?

Registering Applications

This feature allows you to register multiple applications with single-spa. Each application can be loaded dynamically and activated based on the URL path.

const singleSpa = require('single-spa');
singleSpa.registerApplication({
  name: 'app1',
  app: () => System.import('app1'),
  activeWhen: ['/app1'],
  customProps: {}
});
singleSpa.start();

Mounting and Unmounting Applications

This feature allows you to manually mount and unmount applications, giving you fine-grained control over which applications are active at any given time.

const singleSpa = require('single-spa');
singleSpa.registerApplication({
  name: 'app2',
  app: () => System.import('app2'),
  activeWhen: ['/app2'],
  customProps: {}
});
singleSpa.start();

// Manually mount an application
singleSpa.mountRootParcel('app2', { domElement: document.getElementById('app2-container') });

// Manually unmount an application
singleSpa.unmountRootParcel('app2');

Custom Events

This feature allows you to dispatch and listen for custom events, enabling communication between different microfrontends.

const singleSpa = require('single-spa');
singleSpa.registerApplication({
  name: 'app3',
  app: () => System.import('app3'),
  activeWhen: ['/app3'],
  customProps: {}
});
singleSpa.start();

// Dispatch a custom event
window.dispatchEvent(new CustomEvent('custom-event', { detail: { someData: 'data' } }));

// Listen for a custom event
window.addEventListener('custom-event', (event) => {
  console.log(event.detail.someData);
});

Other packages similar to single-spa

Keywords

FAQs

Package last updated on 29 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc