Skip to content
Middle+5 views

How did you resolve conflicts and integration issues between different frameworks and libraries in the microfrontends, including hydration errors and version mismatches?

Practice

Asked at

AI answer

I would start by defining explicit contracts between the microfrontends: who owns routing and state, which dependencies are shared, and how loading and fallback behavior work. Then I would pin compatible versions in lockfiles and check integration in CI, alongside a separate build for each application.

When library versions differ, it is important to determine which dependencies can genuinely be shared as singletons and which are safer to provide independently. For example, a shared React context usually requires aligning the versions of React and React DOM; otherwise, context or hooks errors may occur. Versions and rules for communication between teams should be recorded in configuration and documentation.

Hydration errors usually mean that the HTML rendered by the server differs from the initial client render. I check whether the initial render depends on window, the current time, random values, locale, or data that differs between the server and client. The data for the initial render must be consistent; browser-specific logic should run after mounting. It is also important to verify that the server and client use compatible component versions and the same configuration.

A minimal reproduction, source maps, and loader/bundler logs are useful for debugging. Regressions can be prevented with contract and integration tests, by checking the build of the entire composition, monitoring duplicate dependencies, and gradually enabling changes with the option to roll them back.