next-federation
Remote Components

Remote Components

Share client components from one app and render them inside another app's React tree.

Render a client component from a remote app inside your own React tree. It runs on the host's React, reads the host's context and takes any props, including functions and children.

Runnable example: examples/components-remote (shared context: examples/cart-context).

Next.js hosts server-render a remote component when its build is signed or pinned, and the browser hydrates it. Any other build, and every SPA host, renders it in the browser only. See Integrity.

Islands or remote components?

An island renders on the remote's server, and hydrates in the host page as its own React root. A remote component is client code that runs inside the host's React tree.

IslandsRemote components
ReactThe remote's ownThe host's
Host React contextDoes not cross inReadable through shared modules
PropsPlain JSONAnything a client component takes
Server renderingAlways, on the remoteOn the host, for verified builds only
Remote code in the host processNeverFor verified builds
Remote buildAny server for the protocolVite or Rspack/webpack, Module Federation 2.0

Use islands when the remote must stay isolated or owns its data fetching. Use remote components for interactive pieces that must feel like part of the host.

Set up remote components

Build the remote

Expose client components with Vite or Rspack or webpack.

Sign the build

Set NF_COMPONENTS_SIGNING_KEY in the remote's build (Generate a signing key).

Configure the host

Add the remote to defineFederation and bind each component with createRemoteComponent (Host configuration).

Good to know: A Next.js app cannot be the remote. See Sharing from a Next.js app. Server rendering needs Node.js 20.16 or newer.

Next steps

On this page