---
title: "Discussion on \"Micro-frontends with Next.js and Module Federation\" | Hashnode"
description: "Discussion on \"Micro-frontends with Next.js and Module Federation\". Server-side rendered micro-frontends solution"
url: "https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Micro-frontends with Next.js and Module Federation](https://alibek.dev/micro-frontends-with-nextjs-and-module-federation?utm_source=hashnode&utm_medium=feed)

Server-side rendered micro-frontends solution

Apr 16, 2023 · 8 min read · alibek.dev  
Read the article

-   [#microfrontend](https://hashnode.com/tag/microfrontend)
-   [#nextjs](https://hashnode.com/tag/nextjs)
-   [#module-federation](https://hashnode.com/tag/module-federation)

## Written by

[Alibek Kazhibekov](https://hashnode.com/@alibekdev)

@alibekdev

  
[View profile](https://hashnode.com/@alibekdev)

SWE

## Responses 6

Markdown supported · ⌘↵ to post

[Kim Jongwan](https://hashnode.com/@derek674)

[Dec 11, 2024](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/6759bbcf9d9686a0383b9184)

I read it well, but the link between Next.js and Module Federation you're talking about has so much to lose compared to what you get.

1.  You need to import the components of the remoteApp as a dynamic import (ssr false). The reason is that if you do static or dynamic import (ssr true), you will get a hydration error. You will use the entry.js of the remoteApp that was built at the time of the build on the server, but what if the remoteApp screen was modified in the meantime? You will see a 100% hydration error.
    
2.  Dynamic import (ssr false) fails to render your components on the server, which eventually tarnishes one of Next.js' main objectives of optimizing SEO. It can also cause pages to appear slightly late, page layout to appear slightly broken, blinking, or shaking. Wouldn't it be better to split into monorepo and float servers in multiple locations and redirect different services??
    
3.  Every time a remote app page is added, you have to keep adding and sync pages with shell, so what's the point of doing this hassle at the expense of the aforementioned?
    

[Pedro López](https://hashnode.com/@pedrx1117)

[Jan 22, 2024](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/65ae8c26f1b036266711130d)

Great article. How can you import the hooks from another remote? It would fail if It is dynamic

[Jatin Gundabathula](https://hashnode.com/@JatinGundabathula)

[Aug 29, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64ee6ee10f36f04fe5fe3ed5)

Hi Alibek,

Have you tried using NextJs SSG (Static site generation). we are able to create a next app with SSG and it was running fine with production build (ex: out folder). however when we try to load static remote page (remoteEntry.js) in host application. getStaticProps are not being called.

What we are trying to achieve is to create a next page with SSG and deploy the production build in any S3 bucket (no runtime/ serveless), refer remoteEntry.js in host application

If you any insights on this please help

[jaya prakash](https://hashnode.com/@jai177)

[Jul 31, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64c77311a55a1588fc2c8e4f)

The NextJS component level is necessary. how to write an SSR method. Is there another most recent bundle available?

[jaya prakash](https://hashnode.com/@jai177)

[Jul 27, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64c26e7a3510fc491e1a9165)

How can I expose a component which needs to do an API call to full fill that component? And when I'm using that component in another repo it should be rendered on the server side.

And tell me is there any way to do a serverside call in the next js component level not in the page level?

[Alibek Kazhibekov](https://hashnode.com/@alibekdev)

[Jul 27, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64c26e7a3510fc491e1a9165#reply-64c273d7513c1c494e44e4cc)

What you want it is the new feature of Next.js called App Router, which is not supported by Module federation.

Here you can find how to fetch data on server-side directly in React components [nextjs.org/docs/app/building-your-application/dat…](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching)

[jaya prakash](https://hashnode.com/@jai177)

[Jul 27, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64c26e7a3510fc491e1a9165#reply-64c2772b513c1c494e44e516)

[Alibek Kazhibekov](https://hashnode.com/@alibekdev) For example, in the page router, we have a banner component, to show a banner image we need to do an API call to fetch the image. And I want a reusable component that I can expose and use in another repository and I want all this to happen from the server side. And How to call the SSR method inside the component.

[jaya prakash](https://hashnode.com/@jai177)

[Jul 20, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64b931f3a884f3de56a26816)

I'm facing one issue with Module Federation For NextJs with Tailwind CSS. How to config tailwind css in the NextJS remote app and host app? Or How to get the tailwind CSS code for the remote app to host app and assets images?

[Alibek Kazhibekov](https://hashnode.com/@alibekdev)

[Jul 20, 2023](https://hashnode.com/posts/micro-frontends-with-nextjs-and-module-federation/643c7152deeeb44486e99fbe/comment/64b931f3a884f3de56a26816#reply-64b98156af9957de8741157a)

I recommend you to read this article if you already haven't.

[malcolmkee.com/blog/using-tailwindcss-with-module…](https://malcolmkee.com/blog/using-tailwindcss-with-module-federation/)

It is not nextjs, but similar approach should work in your case.
