Skip to main content

CMicroAppGuest<AppObjects, AppEvents>

Micro-frontend guest application class (singleton). Manages communication between a guest micro-app and its host application. Supports both SSF (Shared Service Framework) and App Bridge communication methods.

Example

const guest = new CMicroAppGuest({
onInit: ({ history, theme, prevState }) => {
console.log('Guest initialized');
},
onMount: ({ container }) => {
// Render your React app
ReactDOM.render(<App />, container);
},
onUnmount: ({ container }) => {
// Cleanup
ReactDOM.unmountComponentAtNode(container);
return { savedState: 'some data' };
}
});

Type Parameters

AppObjects

AppObjects extends ScriptingObjects = Partial<ScriptingObjectTypes>

Type of custom scripting objects

AppEvents

AppEvents extends EventListeners = Events

Type of custom event listeners

Implements

  • IMicroAppGuest<AppObjects, AppEvents>

Accessors

uuid

Get Signature

get uuid(): string;

Unique identifier for the microapp instance.

Returns

string

Implementation of

IMicroAppGuest.uuid

Methods

addScriptingObject()

addScriptingObject<SO>(so: SO, params?: AddScriptingObjectParams): void;

Register a scripting object for child micro-apps to use. Adds the object to both the App Bridge and the SSF Host so guests using either transport can discover it. Always prefer this method over calling appBridge.addScriptingObject() directly.

Type Parameters

SO

SO extends IScriptingObject

Parameters

so

SO

The scripting object to be added.

params?

AddScriptingObjectParams

Optional parameters (e.g. { guestId } to scope to a specific guest).

Returns

void

Implementation of

IMicroAppGuest.addScriptingObject

dispatchEvent()

dispatchEvent<EventId, Params, Options>(params: DispatchEventParam<EventId, Params, Options>): Promise<void | unknown[]>;

Dispatches an event to the child microapp.

Type Parameters

EventId

EventId extends string

Params

Params extends any

Options

Options extends EventOptions

Parameters

params

DispatchEventParam<EventId, Params, Options>

Event parameters.

Returns

Promise<void | unknown[]>

A promise that resolves with the combined results of dispatched events.

Implementation of

IMicroAppGuest.dispatchEvent

getHost()

getHost():
| IMicroAppHost<Partial<ScriptingObjectTypes>, Events>
| IMicroFEHost<Partial<ScriptingObjectTypes>, Events>
| SSFGuest<Partial<ScriptingObjectTypes>, Events>
| undefined;

Returns

| IMicroAppHost<Partial<ScriptingObjectTypes>, Events> | IMicroFEHost<Partial<ScriptingObjectTypes>, Events> | SSFGuest<Partial<ScriptingObjectTypes>, Events> | undefined


getLogger()

getLogger(): MicroFrontEndLogger;

Returns

MicroFrontEndLogger


getObject()

getObject<ObjectId>(objectId: ObjectId): Promise<AppObjects[ObjectId] | null>;

Retrieves a reference to a scripting object (or proxy) by its unique name.

Type Parameters

ObjectId

ObjectId extends string

Parameters

objectId

ObjectId

The unique name of the scripting object.

Returns

Promise<AppObjects[ObjectId] | null>

A promise that resolves to the scripting object reference or null if not found.

Implementation of

IMicroAppGuest.getObject

getProps()

getProps(): GuestProps<Partial<ScriptingObjectTypes>, Events>;

Returns

GuestProps<Partial<ScriptingObjectTypes>, Events>


getRef()

getRef<T>(): T | null;

Retrieves a generic reference of type T.

Type Parameters

T

T

Returns

T | null

The reference of type T or null if not available.

Deprecated

This method is deprecated and will be removed in future versions.

Implementation of

IMicroAppGuest.getRef

init()

init(options: InitOptions<AppObjects, AppEvents>): Promise<void>;

Initializes the microapp with the provided options.

Parameters

options

InitOptions<AppObjects, AppEvents>

Options for initializing the microapp.

Returns

Promise<void>

A promise that resolves when initialization is complete.

Implementation of

IMicroAppGuest.init

initialize()

initialize(): Promise<ModuleParameters>;

Guest-initiated lifecycle: discovers the host and applies module parameters if available. After this resolves the guest is ready to render. Requires selfInitialize: true in the constructor so the bridge skips calling init() / mount() on this guest.

The module scripting object is optional — if the host did not register one, a warning is logged and the guest proceeds with its own config.

Returns

Promise<ModuleParameters>

module parameters provided by the host, or a minimal object with moduleId


mount()

mount(options?: MountOptions): Promise<void>;

Mounts the microapp with the provided options.

Parameters

options?

MountOptions = ...

Options for mounting the microapp.

Returns

Promise<void>

A promise that resolves when the microapp is successfully mounted.

Implementation of

IMicroAppGuest.mount

navigate(url: To, state?: any): void;

Navigates the microapp to a specified URL with an optional state.

Parameters

url

To

The target URL to navigate to.

state?

any

Optional state to pass during navigation.

Returns

void

Implementation of

IMicroAppGuest.navigate

removeScriptingObject()

removeScriptingObject(objectId: Extract<keyof AppObjects, string>): void;

removes scripting object from child microapp use

Parameters

objectId

Extract<keyof AppObjects, string>

unique id of the scripting object

Returns

void

Implementation of

IMicroAppGuest.removeScriptingObject

subscribe()

subscribe<EventId>(params: SubscribeParam<EventId, AppEvents[EventId]>): string;

subscribe to the scripting object event

Type Parameters

EventId

EventId extends string

Parameters

params

SubscribeParam<EventId, AppEvents[EventId]>

the parameters for the subscription

Returns

string

Implementation of

IMicroAppGuest.subscribe

unmount()

unmount(options: MountOptions): Promise<JSONValue>;

Unmounts the microapp with the provided options.

Parameters

options

MountOptions

Options for unmounting the microapp.

Returns

Promise<JSONValue>

A promise that resolves to a JSON value upon successful unmounting.

Implementation of

IMicroAppGuest.unmount

unsubscribe()

unsubscribe<EventId>(params: UnsubscribeParam<EventId>): void;

unsubscribe from the scripting object event

Type Parameters

EventId

EventId extends string

Parameters

params

UnsubscribeParam<EventId>

parameters for the unsubscription

Returns

void

Implementation of

IMicroAppGuest.unsubscribe

getInstance()

static getInstance<AppObjects, AppEvents>(params?: ConstructorParams): CMicroAppGuest<AppObjects, AppEvents>;

Type Parameters

AppObjects

AppObjects extends ScriptingObjects = Partial<ScriptingObjectTypes>

AppEvents

AppEvents extends EventListeners = Events

Parameters

params?

ConstructorParams

Returns

CMicroAppGuest<AppObjects, AppEvents>


isHosted()

static isHosted(): boolean;

Returns

boolean


isInitialized()

static isInitialized(): boolean;

Returns

boolean