Vue Bridge (for Vue v3)
@module-federation/bridge-vue3 provides a bridge utility function for Vue V3 applications. The provided createBridgeComponent can be used to export application-level modules, and createRemoteAppComponent can be used to load application-level modules.
Installation
Type
Example
Remote
Host
Routing Modes
The bridge supports three routing modes that determine how the remote application manages its internal navigation:
Hash route example
Memory route example
Parameters
createRemoteAppComponent
optionsloader- type:
() => Promise<Module> - Purpose: Used to load remote modules, e.g.,
loadRemote('remote1/export-app')orimport('remote1/export-app')
- type:
export- type:
string - Purpose: Used to specify module export
- type:
asyncComponentOptions- type:
Omit<AsyncComponentOptions, 'loader'> - Purpose: Parameters that will be passed to defineAsyncComponent, except for the loader parameter
- type:
rootAttrs- type:
Record<string, unknown> - Purpose: Attributes that will be bound to the root container where the remote Vue application will be mounted
- type:
memoryRoute- type:
{ entryPath: string } - Purpose: When provided, the remote application will use memory history (
createMemoryHistory) instead of the default web history. TheentryPathsets the initial route the remote app navigates to on mount. Useful when the remote app is rendered in an isolated context (e.g., a modal or sandbox) where it should not modify the browser URL.
- type:
hashRoute- type:
boolean - Purpose: When set to
true, the remote application will use hash-based history (createWebHashHistory) instead of the default web history. Route paths are automatically prefixed with thebasename. Use this when the host application also uses hash-based routing.
- type:
- ReturnType
- type:
VueComponent - Purpose: Used to render remote module components
- type:
createBridgeComponent
bridgeInfo- type:
{ rootComponent: VueComponent; appOptions?: (params: AddOptionsFnParams) => ({ router?: Router }) } - Purpose: Used to pass the root component
appOptionsreceives the following params:app: The Vue application instancebasename: The base path derived from the host routememoryRoute: Memory route configuration (if provided by the host)hashRoute: Whether hash-based routing is enabled (if provided by the host)
- type:
- ReturnType
- type:
() => { render: (info: RenderFnParams) => void; destroy: (info: { dom: HTMLElement}) => void; }
- type: