New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

microapp-loader

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

microapp-loader

A React component library for loading and rendering micro applications

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

MicroApp Loader

A React component library for loading and rendering micro applications dynamically. Perfect for micro-frontend architectures and modular application development.

Installation

npm install microapp-loader

Usage

Basic Usage

import { MicroAppRender } from 'microapp-loader';

function App() {
  return (
    <div>
      <h1>My Application</h1>
      <MicroAppRender 
        manifestUrl="https://example.com/my-microapp/manifest.json"
        className="micro-app-container"
      />
    </div>
  );
}

Using the Hook Directly

import { useMicroApp } from 'microapp-loader';

function CustomMicroAppRenderer({ manifestUrl }: { manifestUrl: string }) {
  const { 
    partialContent, 
    cssContent, 
    loading, 
    error, 
    manifest, 
    executeJS 
  } = useMicroApp(manifestUrl);

  if (loading) return <div>Loading micro app...</div>;
  if (error) return <div>Error: {error}</div>;

  return (
    <div>
      {cssContent && <style dangerouslySetInnerHTML={{ __html: cssContent }} />}
      <div dangerouslySetInnerHTML={{ __html: partialContent }} />
      <button onClick={executeJS}>Execute JavaScript</button>
    </div>
  );
}

Manifest Format

Your micro application should provide a JSON manifest with the following structure:

{
  "version": "1.0.0",
  "name": "my-microapp",
  "entry": "https://example.com/my-microapp/main.js",
  "scripts": [
    "https://example.com/my-microapp/additional-script.js"
  ],
  "styles": [
    "https://example.com/my-microapp/styles.css"
  ],
  "partials": [
    "https://example.com/my-microapp/template.html"
  ],
  "containerClass": "my-microapp-container"
}

API Reference

MicroAppRender Component

PropTypeRequiredDescription
manifestUrlstringURL to the micro app manifest JSON file
classNamestringCSS class name for the container

useMicroApp Hook

Returns an object with the following properties:

PropertyTypeDescription
partialContentstringHTML content from the micro app
cssContentstringCSS styles from the micro app
jsContentstringJavaScript code from the micro app
loadingbooleanLoading state
errorstring | nullError message if any
manifestMicroAppManifest | nullParsed manifest data
executeJS() => voidFunction to execute the JavaScript code

TypeScript Support

This package includes full TypeScript support with exported types:

  • MicroAppManifest
  • UseMicroAppReturn
  • MicroAppRenderProps

Next.js Usage

This package works seamlessly with Next.js applications. Simply import and use the components as you would any other React component.

License

ISC

Keywords

react

FAQs

Package last updated on 07 Jul 2025

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