Get the prerendered RSC stream for hydration. Usually passed directly to your
react-server-dom-xyz/client
's createFromReadableStream
.
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
import {
unstable_getRSCStream as getRSCStream,
unstable_RSCHydratedRouter as RSCHydratedRouter,
} from "react-router";
import type { unstable_RSCPayload as RSCPayload } from "react-router";
createFromReadableStream(getRSCStream()).then(
(payload: RSCServerPayload) => {
startTransition(async () => {
hydrateRoot(
document,
<StrictMode>
<RSCHydratedRouter ...props />
</StrictMode>,
{
// Options
}
);
});
}
);
function getRSCStream(): ReadableStream<any>
A ReadableStream
that contains the RSC data for hydration.