@lensmcp/client-runtime
v1.22.1
Published
LensMCP browser-side capture layer — errors, console, fetch, and route changes streamed to the LensMCP bridge. Import '@lensmcp/client-runtime/auto' for a zero-build install in any host.
Maintainers
Readme
@lensmcp/client-runtime
The browser-side capture layer for LensMCP. It connects to the
@lensmcp/bridge WebSocket and streams one envelope per
observed event — window.onerror / unhandledrejection, console.*,
fetch timing, and History API route changes — plus a
window.__LENSMCP_PUBLISH__ hook that in-page instrumentation
(@lensmcp/react-instrumentation, @lensmcp/valtio-instrumentation) rides.
It is strictly passive: it never mutates app state, swallows errors, or changes scheduling.
No-build install
For any host without a LensMCP build plugin — webpack, Next.js, or no bundler at all — import the side-effecting entry at your app's top level:
import '@lensmcp/client-runtime/auto';It resolves the bridge WebSocket endpoint at runtime, so nothing needs to bake the URL in at build time. Resolution order:
globalThis.__LENSMCP_WS_URL__— a fullws://…URL<meta name="lensmcp-ws" content="ws://…">ws://<host>:<port>from__LENSMCP_WS_HOST__/<meta name="lensmcp-ws-host">/location.hostnameand__LENSMCP_WS_PORT__/<meta name="lensmcp-ws-port">/ the default port (5747)
Run the bridge alongside your dev server:
lensmcp bridge # ws://127.0.0.1:5747, forwards to .lensmcp/events.jsonlFor explicit control, call the installer yourself instead of importing /auto:
import { installLensmcp } from '@lensmcp/client-runtime';
installLensmcp({ wsUrl: 'ws://127.0.0.1:5747' });With a build plugin
When @lensmcp/vite-plugin (or another LensMCP host adapter) is active it
injects an equivalent runtime for you with the bridge port already wired —
you don't import anything.
