{"slug": "show-hn-nirnam-a-browser-native-message-bus-and-ai-agent-framework-for-mfes", "title": "Show HN: Nirnam – a browser-native message bus and AI agent framework for MFEs", "summary": "Nirnam, a browser-native message bus and AI agent framework for micro-frontends, has been released as an open-source npm package. It provides a three-layer hybrid message bus enabling pub/sub, request-reply, streaming, and agent registration across scripts, iframes, and Web Workers without a backend. The framework includes multiple examples demonstrating integration with React, Angular, Module Federation, and MCP-based AI agents.", "body_md": "A three-layer hybrid message bus for micro-frontend communication and browser-native AI agents.\n\nNirnam gives every script on a page — Module Federation remotes, iframes, Web Workers, plain `<script>`\n\ntags — a shared message bus without a backend. It handles pub/sub, request-reply, streaming, agent registration, and MCP transport, all routed through a SharedWorker.\n\n**Three layers, one API:**\n\n| Layer | Mechanism | Scope |\n|---|---|---|\n| 1 | BroadcastChannel | Cross-tab fan-out (fire-and-forget pub/sub) |\n| 2 | Blob-URL SharedWorker | Within-page registry, routing, request-reply, streaming |\n| 3 | Static-URL SharedWorker | True cross-tab routing via build plugins (opt-in) |\n\nYou always call `createBus()`\n\n— Nirnam picks the right layer automatically.\n\n```\nnpm install @palinc/nirnam\n```\n\n[Full usage guide and API reference →](/shaurcasm/nirnam/blob/main/Library/README.md)\n\n``` js\nimport { createBus } from '@palinc/nirnam';\n\nconst bus = createBus();\n\n// One MFE handles cart requests\nbus.handle('cart:total', async ({ items }) => {\n  return { total: items.reduce((s, i) => s + i.price, 0) };\n});\n\n// Another MFE calls it\nconst { total } = await bus.request('cart:total', { items: [{ price: 9.99 }] });\nLibrary/         @palinc/nirnam source + tests\nExamples/\n  transport/               pub/sub · request-reply · streaming basics (Vite)\n  transport-with-persistence/  message replay via IndexedDB (Rsbuild)\n  react-mfe/               two React MFEs sharing state (Module Federation)\n  agents/                  chat · filesystem · pipeline agents (Rsbuild)\n  cross-tab-agent/         host tab runs LLM; other tabs proxy via bus (Vite)\n  mcp-agent/               Document Q&A with MCP servers + Ollama (Rsbuild + MF)\n  static-worker/           raw SharedWorker without MFEs (Vite)\n  angular-react/           Angular host + React remote (planned)\n```\n\nEach example is self-contained. Pick one:\n\n```\ncd Examples/transport\nnpm install\nnpm run dev\n```\n\nThe `mcp-agent`\n\nexample needs all three apps running:\n\n```\ncd Examples/mcp-agent/ollama-agent && npm install && npm run dev  # :3001\ncd Examples/mcp-agent/scribe-agent && npm install && npm run dev  # :3002\ncd Examples/mcp-agent/host          && npm install && npm run dev  # :3000\ncd Library\nnpm install\nnpm run build        # one-off build\nnpm run build:watch  # watch mode\nnpm test             # jest test suite\nnpm run test:coverage\n```\n\nThe library is built with Rollup into 12 entry points (ESM + CJS + `.d.ts`\n\nper subpath export). Source is in `Library/src/`\n\n.\n\nThe simplest starting point. A single-page vanilla JS app demonstrating all three message patterns: pub/sub, request-reply, and streaming. No framework, no bundler magic.\n\nExtends the transport example with IndexedDB persistence. Late-joining subscribers can replay the last N messages on subscribe.\n\nTwo independently-deployed React apps (host + remote) that share state through the bus using Module Federation. Shows `useNirnam`\n\nand `useNirnamPublish`\n\n.\n\nThree agents in one app — a chat agent, a filesystem agent with File System Access API tools, and a pipeline of two agents where one feeds into the other. Uses the Rsbuild build plugin for Layer 3.\n\nOne \"host\" tab registers a `scope: 'page'`\n\nagent that owns the LLM + tools. Any other tab creates an `AgentProxy`\n\nand gets the same chat interface routed over the static SharedWorker. Open two tabs and chat from either.\n\nThree Module Federation apps. Two remotes (`ollama-agent`\n\n, `scribe-agent`\n\n) expose React components that also spin up MCP servers over `NirnamMCPTransport`\n\n. The host connects MCP clients to both and orchestrates a document Q&A workflow.\n\nRaw SharedWorker setup without any MFE framework — useful if you want to understand Layer 3 in isolation.", "url": "https://wpnews.pro/news/show-hn-nirnam-a-browser-native-message-bus-and-ai-agent-framework-for-mfes", "canonical_source": "https://github.com/shaurcasm/nirnam", "published_at": "2026-06-27 12:27:25+00:00", "updated_at": "2026-06-27 12:34:59.684390+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "generative-ai"], "entities": ["Nirnam", "Module Federation", "SharedWorker", "BroadcastChannel", "IndexedDB", "Ollama", "MCP", "Vite"], "alternates": {"html": "https://wpnews.pro/news/show-hn-nirnam-a-browser-native-message-bus-and-ai-agent-framework-for-mfes", "markdown": "https://wpnews.pro/news/show-hn-nirnam-a-browser-native-message-bus-and-ai-agent-framework-for-mfes.md", "text": "https://wpnews.pro/news/show-hn-nirnam-a-browser-native-message-bus-and-ai-agent-framework-for-mfes.txt", "jsonld": "https://wpnews.pro/news/show-hn-nirnam-a-browser-native-message-bus-and-ai-agent-framework-for-mfes.jsonld"}}