A React Server Components (RSC) meta-framework that implements federated architecture using Rspack and Module Federation. Inspired by Jacob Ebey's federated RSC work, nano-forge enables composable server-side rendering with cross-container component sharing.
Nano-forge implements the federated RSC architecture where:
- HTTP is the API for the server layer
- RSC payloads are composable across different remote containers
- Client references have global IDs that work across federated boundaries
- Module Federation enables runtime loading of components from remote containers
┌─────────────────────────────────────────────────────────────────┐
│ Nano-Forge Framework │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Host App │ │ Remote App │ │ Remote App │ │
│ │ (Orchestrator) │ │ (Micro-frontend│ │ (Micro-frontend│ │
│ │ │ │ Component) │ │ Component) │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ │ │ │ │
│ └─────────────────────┼─────────────────────┘ │
│ │ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Module Federation Layer │ │
│ │ • Shared Dependencies (React, etc.) │ │
│ │ • Global Client Reference IDs │ │
│ │ • Runtime Component Loading │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ RSC Streaming Layer │ │
│ │ • Server Components render to RSC streams │ │
│ │ • Client boundaries encoded as references │ │
│ │ • Cross-container component composition │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Build System (Rspack) │ │
│ │ • Multi-environment builds (browser/ssr/server) │ │
│ │ • Module federation configuration │ │
│ │ • Client component detection and chunking │ │
│ └─────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
The build system and development tooling
Provides Rspack-based build configuration with Module Federation support for creating federated RSC applications.
The runtime framework primitives
Core RSC runtime, client/server boundaries, remote component loading, and streaming infrastructure.
Reference implementations
Working examples of host (orchestrator) and remote (micro-frontend) applications demonstrating federated RSC patterns.
The CLI package provides the build system integration and development tools for creating federated RSC applications.
Main plugin entry point - Configures Rspack with three build environments:
browser- Client-side bundle with module federationssr- Server-side rendering bundleserver- React Server Components bundle
Sets up module federation configuration and remote container definitions.
Rspack plugin system - Core build plugins:
FrameworkPlugin- Detects"use client"and"use server"directivesFrameworkClientPlugin- Configures module federation for client bundlesFrameworkServerPlugin- Handles server-side remote definitionsRspackCircularDependencyPlugin- Prevents circular dependencies
Command-line interface - Development server and build commands.
Client-side runtime - Module federation runtime configuration for browser environments.
RSC webpack loader - Processes React Server Components and client boundaries during build.
The core runtime that implements the federated RSC architecture.
Server-side RSC framework - Core server functionality:
defineApp()- Creates RSC application with route definitionsdefaultRenderMatch()- Default route matching and rendering logic- URL pattern matching - File-system based routing
- RSC streaming - Renders components to RSC payload streams
Client-side RSC framework - Client runtime:
RemoteContextProvider- Context for managing remote RSC streamsRemoteComponent- Renders RSC streams as React componentsOutletProvider/Outlet- Layout and nested routing system
Remote component system - Federated component loading:
RemoteRoute- Loads and renders components from remote containersFrameworkRemote- Configuration for remote container endpoints- Cross-container communication - Fetches RSC streams from remote servers
Server-side rendering - SSR implementation:
renderToReadableStream()- Renders React components to HTML streamscreateFromReadableStream()- Reconstructs React elements from RSC streamsInlinePayload- Inlines RSC data for client hydration
Browser hydration - Client-side application bootstrap:
ClientRouter- Client-side navigation with RSC streaming- Navigation API integration - Modern browser navigation
- Progressive enhancement - Works with or without SSR
SSR bootstrap - Server-side rendering entry point:
handleRequest()- Processes HTTP requests for SSR- RSC to HTML conversion - Transforms RSC streams to HTML
- Hydration data injection - Embeds RSC data for client pickup
Platform-specific RSC implementations:
react-server-dom.client.*.ts- Client-side RSC stream processingreact-server-dom.server.*.ts- Server-side RSC stream generationreact-dom.server.*.ts- Server-side HTML rendering
entry.browser.ts- Browser application entryentry.ssr.ts- SSR application entryclient.internal.ts- Internal client utilitiesutils.ts- Shared utilitiesruntime.client.ts- Client runtime configurationruntime.server.ts- Server runtime configuration
Reference implementations demonstrating federated RSC patterns.
The orchestrator application that composes remote micro-frontends.
Server configuration - Defines the host application routing:
- Layout routes - Provides shared UI shell
- Remote route delegation - Delegates specific routes to remote containers
- 404 handling - Fallback for unmatched routes
Shared layout - Common UI shell with navigation that wraps remote content.
Server entry point - Exports the configured RSC application.
Development server - Node.js server for development with hot reload.
Build configuration - Rspack configuration with:
- Module federation setup - Configures remote container consumption
- Multi-environment builds - Browser, SSR, and server builds
- Remote definitions - Points to remote container endpoints
A micro-frontend that exposes components for consumption by host applications.
Server configuration - Defines routes exposed by this remote:
/route - Home page component/aboutroute - About page component
Server component - React Server Component that imports client components.
Client component - Interactive React component marked with "use client":
Counter- Stateful counter component demonstrating client-side interactivity
Server component - Simple about page component.
Development server - Standalone server that can run independently.
Build configuration - Rspack configuration with:
- Module federation exposure - Exposes components for consumption
- Client component chunking - Separates client components into federated chunks
# Start remote micro-frontend
cd examples/remote
npm run dev # Runs on localhost:3001
# Start host application
cd examples/host
npm run dev # Runs on localhost:3000- Browser requests
http://localhost:3000/ - Host application matches route and delegates to remote
- Remote container fetches RSC stream from
http://localhost:3001/.data - RSC stream contains server-rendered content + client boundaries
- Client boundaries are resolved via module federation
- Final rendering composes host layout + remote content + federated client components
- Client components are detected via
"use client"directive - Module federation exposes client components as shared chunks
- Three builds are generated:
- Browser bundle - Client-side code with module federation
- SSR bundle - Server-side rendering with module federation
- Server bundle - React Server Components (no module federation)
- Server components run on the server and stream RSC payloads
- Client components are loaded via module federation at runtime
- RSC streams are cached and shared between server and client
- Navigation is handled client-side with RSC streaming
Unlike traditional RSC frameworks, nano-forge enables cross-container composition:
- Multiple RSC servers can be composed together
- Client references work across container boundaries
- Shared dependencies are deduplicated via module federation
Client components get globally unique IDs in the format:
rsc/remote/client/{container}/{module}#{export}
Servers expose RSC endpoints that other servers can consume:
GET /about.data
Accept: text/x-component
- Shared scope - React and other dependencies shared between containers
- Runtime loading - Components loaded on-demand from remote containers
- Development isolation - Each container can be developed independently
- Micro-frontend Architecture - Independent deployment and development
- Server-side Composition - SEO-friendly, fast initial page loads
- Progressive Enhancement - Works with and without JavaScript
- Shared Dependencies - Efficient bundle sizes via module federation
- Type Safety - Full TypeScript support across container boundaries
- Developer Experience - Hot reload, fast builds with Rspack
| Feature | Nano-Forge | Next.js | Remix |
|---|---|---|---|
| RSC Support | ✅ Full | ✅ Full | ❌ No |
| Module Federation | ✅ Native | ❌ No | ❌ No |
| Micro-frontends | ✅ Built-in | ||
| Server Composition | ✅ HTTP-based | ❌ No | ❌ No |
| Build System | Rspack | Webpack/Turbopack | Vite/esbuild |
Nano-forge is specifically designed for federated RSC architectures where multiple teams need to compose server-rendered React applications with shared client-side interactivity.