{"_id":"rsc-html-stream","_rev":"3808582","name":"rsc-html-stream","description":"Inject an RSC payload into an HTML stream and read it back","dist-tags":{"latest":"0.0.6"},"maintainers":[{"name":"devongovett","email":""}],"time":{"modified":"2025-06-05T11:07:38.000Z","created":"2024-02-19T19:07:31.265Z","0.0.6":"2025-05-09T19:06:30.790Z","0.0.5":"2025-03-20T16:45:33.336Z","0.0.4":"2024-11-30T23:37:40.168Z","0.0.3":"2024-02-27T03:25:59.686Z","0.0.2":"2024-02-19T23:24:22.618Z","0.0.1":"2024-02-19T23:17:00.817Z","0.0.0":"2024-02-19T19:07:31.265Z"},"users":{},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"versions":{"0.0.6":{"name":"rsc-html-stream","version":"0.0.6","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"rsc-html-stream@0.0.6","scripts":{"start":"node server.js"},"gitHead":"9938c93975380d13189363565897fb66a59ffb05","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"shasum":"4943c36021b0724334a1325a5732c0c9fedaa771","size":4159,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.6.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rsc-html-stream_0.0.6_1746817590574_0.624163227434861"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-05-09T19:06:30.790Z","publish_time":1746817590790,"_source_registry_name":"default","_cnpm_publish_time":1746817590790},"0.0.5":{"name":"rsc-html-stream","version":"0.0.5","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"rsc-html-stream@0.0.5","scripts":{"start":"node server.js"},"gitHead":"c9d74e871ecf6d1655418dd73aea77480d474423","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"shasum":"3bf1ba2181c2f269b3541310ac83d7deef56d3c9","size":4020,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.5.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rsc-html-stream_0.0.5_1742489133134_0.15999779517433543"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-20T16:45:33.336Z","publish_time":1742489133336,"_source_registry_name":"default","_cnpm_publish_time":1742489133336},"0.0.4":{"name":"rsc-html-stream","version":"0.0.4","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"rsc-html-stream@0.0.4","scripts":{"start":"node server.js"},"gitHead":"e776c6de76f855ebda0c9d2da7ee1ca07efd72ce","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"shasum":"0ae70518eeac305852533b9ad60aefacce72ed95","size":3997,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.4.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-html-stream_0.0.4_1733009859974_0.2504430892177689"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-11-30T23:37:40.168Z","publish_time":1733009860168,"_source_registry_name":"default","_cnpm_publish_time":1733009860168},"0.0.3":{"name":"rsc-html-stream","version":"0.0.3","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"rsc-html-stream@0.0.3","scripts":{"start":"node server.js"},"gitHead":"87fe93d29f9140e2ef66f955ef0e4a666d8c6978","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_nodeVersion":"20.9.0","_npmVersion":"10.4.0","dist":{"shasum":"00fadd87b1e8884b1fbbe8462c2fcc8372976247","size":3654,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.3.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-html-stream_0.0.3_1709004359534_0.6418629763328805"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-27T03:25:59.686Z","publish_time":1709004359686,"_source_registry_name":"default","_cnpm_publish_time":1709004359686},"0.0.2":{"name":"rsc-html-stream","version":"0.0.2","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"rsc-html-stream@0.0.2","scripts":{"start":"node server.js"},"gitHead":"1ff7350f280243ee23f7133c26892f9b9065a663","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_nodeVersion":"20.5.0","_npmVersion":"9.8.0","dist":{"shasum":"6e59c8788e64a96b7122ea87f4d5232c06f784f4","size":3635,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.2.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-html-stream_0.0.2_1708385062458_0.36848808039226943"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-19T23:24:22.618Z","publish_time":1708385062618,"_source_registry_name":"default","_cnpm_publish_time":1708385062618},"0.0.1":{"name":"rsc-html-stream","version":"0.0.1","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"rsc-html-stream@0.0.1","scripts":{"start":"node server.js"},"gitHead":"5d98299a46901bc49e6a00c695aacbe7853a0284","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_nodeVersion":"20.5.0","_npmVersion":"9.8.0","dist":{"shasum":"8524551aa3efe36d30574e7c5e7de52faaef7f33","size":3631,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.1.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-html-stream_0.0.1_1708384620643_0.678371244206655"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-19T23:17:00.817Z","publish_time":1708384620817,"_source_registry_name":"default","_cnpm_publish_time":1708384620817},"0.0.0":{"name":"rsc-html-stream","version":"0.0.0","description":"Inject an RSC payload into an HTML stream and read it back","type":"module","exports":{"./client":{"types":"./client.d.ts","default":"./client.js"},"./server":{"types":"./server.d.ts","default":"./server.js"}},"repository":{"type":"git","url":"git+https://github.com/devongovett/rsc-html-stream.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","scripts":{"start":"node server.js"},"gitHead":"36303e1ce3811bb62450ec66c5bfaa3075646565","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","_id":"rsc-html-stream@0.0.0","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"shasum":"073ae5959238064994d1713ecffce34ce3fbdae9","size":2566,"noattachment":false,"key":"/rsc-html-stream/-/rsc-html-stream-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rsc-html-stream/download/rsc-html-stream-0.0.0.tgz"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"maintainers":[{"name":"devongovett","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-html-stream_0.0.0_1708369651123_0.039326559752444146"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-19T19:07:31.265Z","publish_time":1708369651265,"_source_registry_name":"default","_cnpm_publish_time":1708369651265}},"readme":"# rsc-html-stream\n\nA small utility to inject a React Server Components payload into an HTML stream on the server, and read it back into a stream on the client. This is useful when rendering RSC to an initial HTML response to avoid an extra HTTP request to hydrate the page on the client. Instead, the payload is injected into the initial HTML as a series of `<script>` elements, and re-combined together into a `ReadableStream` on the client.\n\n## Usage\n\nOn the server, use the `injectRSCPayload` function from `rsc-html-stream/server` to create a `TransformStream` that injects the RSC payload stream into the HTML stream.\n\n```js\nimport {renderToReadableStream} from 'react-server-dom-BUNDLER/server.edge';\nimport {createFromReadableStream} from 'react-server-dom-BUNDLER/client.edge';\nimport {renderToReadableStream as renderHTMLToReadableStream} from 'react-dom/server.edge';\nimport {injectRSCPayload} from 'rsc-html-stream/server';\n\n// Render a component to RSC payload using bundler integration package.\nlet rscStream = renderToReadableStream(<App />);\n\n// Fork the stream, and render it to HTML.\nlet [s1, s2] = rscStream.tee();\nlet data;\nfunction Content() {\n  data ??= createFromReadableStream(s1);\n  return React.use(data);\n}\n\nlet htmlStream = await renderHTMLToReadableStream(<Content />);\n\n// Inject the RSC stream into the HTML stream.\nlet response = htmlStream.pipeThrough(injectRSCPayload(s2));\n```\n\nOn the client, use the `rscStream` from `rsc-html-stream/client` to hydrate the page. This is a `ReadableStream` that includes the RSC payload injected into the HTML by the server.\n\n```js\nimport ReactServerDOMReader from 'react-server-dom-BUNDLER/client';\nimport {rscStream} from 'rsc-html-stream/client';\n\nlet data;\nfunction Content() {\n  data ??= ReactServerDOMReader.createFromReadableStream(\n    rscStream\n  );\n  return React.use(data);\n}\n```\n","_attachments":{},"homepage":"https://github.com/devongovett/rsc-html-stream#readme","bugs":{"url":"https://github.com/devongovett/rsc-html-stream/issues"},"license":"MIT"}