@stream-mdx/worker
v0.1.1
Published
Worker client utilities and shared worker helpers for the Streaming Markdown V2 pipeline
Downloads
844
Readme
@stream-mdx/worker
Worker client utilities and hosted worker bundle used by StreamMDX.
Most consumers interact with this package indirectly via <StreamingMarkdown />. You only need @stream-mdx/worker directly if you want explicit control over worker instantiation, MDX compilation parity helpers, or strict CSP setups.
Install
npm install @stream-mdx/workerHosted worker bundle (recommended)
For production, host the worker bundle from static assets (avoids blob: CSP requirements):
mkdir -p public/workers
cp node_modules/@stream-mdx/worker/dist/hosted/markdown-worker.js public/workers/markdown-worker.jsThen point StreamMDX at it:
<StreamingMarkdown worker="/workers/markdown-worker.js" />Node / CLI worker threads
To run the hosted worker bundle in Node (e.g., Ink TUIs), use:
import { createWorkerThread } from "@stream-mdx/worker/node";This spawns a worker_threads worker and installs WebWorker-like shims so the hosted bundle can run under Node.
MDX compilation parity helper
If you compile MDX on the server (e.g. Next.js API route), use the same compilation logic as the worker:
import { compileMdxContent } from "@stream-mdx/worker/mdx-compile";See docs/REACT_INTEGRATION_GUIDE.md for the full wiring and parity notes.
Docs
- React integration guide:
docs/REACT_INTEGRATION_GUIDE.md - Security model / CSP:
docs/SECURITY_MODEL.md - Plugins & custom worker bundles:
docs/STREAMING_MARKDOWN_PLUGINS_COOKBOOK.md
