
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
create-react-microfrontend
Advanced tools
Library that provides the ability to render a Create React App project within another React app.
Library that provides the ability to render a Create React App project within another React app.
yarn add
or npm install
create-react-microfrontend
import { createMicroFrontend } from 'create-react-microfrontend'
const reactRender = (renderProps, container) => {
ReactDOM.render(
<Router history={customHistory}>
<App {...renderProps} />
</Router>,
container
)
}
createMicroFrontend(
reactRender,
'POP', // App name
false, // noMFE
props, // localProps
'root' // containerId
)
The reactRender
function needs to be created to allow applying props from the parent app, and which component to apply them to.
If, for instance, you had some further HOCs which wrapped around <App />
. It also allows for the flexibility of applying props locally, for development pruposes.
To develop locally, in the third argument, pass true
(the noMFE option), and it will render the app to the containerId
provided, and will apply the supplied localProps
to the reactRender
function. This noMFE option would be a good place to use process.env.NODE_ENV === 'development'
.
The appName
will need to match the appName
in the next step to retrieve the matching MFE.
Example :
import { useMicrofrontendReact } from 'create-react-microfrontend';
const [isLoaded, POP] = useMicrofrontendReact('POP', 'http://localhost:3000');
React.useEffect(() => {
if (!isLoaded) {
return;
}
const { render, unmount } = POP;
render(id, POPProps);
return () => unmount(id);
}, [isLoaded]);
useMicrofrontendReact(appName, microFrontendURL)
returns isLoaded
and the application functions of render(id, props)
and unmount(id)
. Once the application is fetched, isLoaded
returns true and the app can be rendered, and then unmount
can be used in the cleanup as a returned function to a useEffect
.
FAQs
Library that provides the ability to render a Create React App project within another React app.
We found that create-react-microfrontend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.