From 828cb316c6def8a6a5e1fc5affd4388a2140ea4f Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Mon, 26 May 2025 06:37:04 -0700 Subject: [PATCH 1/2] chore: mark new APIs as unstable chore: add `use client` directive to dom-export --- integration/helpers/rsc-parcel/src/entry.browser.tsx | 6 +++--- integration/helpers/rsc-parcel/src/entry.rsc.ts | 2 +- integration/helpers/rsc-parcel/src/entry.ssr.tsx | 4 ++-- integration/helpers/rsc-vite/src/entry.browser.tsx | 6 +++--- integration/helpers/rsc-vite/src/entry.rsc.tsx | 2 +- integration/helpers/rsc-vite/src/entry.ssr.tsx | 5 ++++- packages/react-router/dom-export.ts | 2 ++ packages/react-router/index.ts | 12 +++++++++--- packages/react-router/rsc-export.ts | 2 +- playground/rsc-parcel/src/entry.browser.tsx | 6 +++--- playground/rsc-parcel/src/entry.rsc.ts | 2 +- playground/rsc-parcel/src/entry.ssr.tsx | 4 ++-- playground/rsc-vite/src/browser/entry.browser.tsx | 6 +++--- playground/rsc-vite/src/rsc/entry.rsc.tsx | 2 +- playground/rsc-vite/src/ssr/entry.ssr.tsx | 5 ++++- 15 files changed, 40 insertions(+), 26 deletions(-) diff --git a/integration/helpers/rsc-parcel/src/entry.browser.tsx b/integration/helpers/rsc-parcel/src/entry.browser.tsx index 2f412c8596..a8b854a4e2 100644 --- a/integration/helpers/rsc-parcel/src/entry.browser.tsx +++ b/integration/helpers/rsc-parcel/src/entry.browser.tsx @@ -3,9 +3,9 @@ import * as React from "react"; import { hydrateRoot } from "react-dom/client"; import { - createCallServer, - getServerStream, - RSCHydratedRouter, + unstable_createCallServer as createCallServer, + unstable_getServerStream as getServerStream, + unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; import type { ServerPayload } from "react-router/rsc"; import { diff --git a/integration/helpers/rsc-parcel/src/entry.rsc.ts b/integration/helpers/rsc-parcel/src/entry.rsc.ts index 8085fe18e3..e786fbb53a 100644 --- a/integration/helpers/rsc-parcel/src/entry.rsc.ts +++ b/integration/helpers/rsc-parcel/src/entry.rsc.ts @@ -10,7 +10,7 @@ import { import { type DecodeCallServerFunction, type DecodeFormActionFunction, - matchRSCServerRequest, + unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; import { routes } from "./routes"; diff --git a/integration/helpers/rsc-parcel/src/entry.ssr.tsx b/integration/helpers/rsc-parcel/src/entry.ssr.tsx index 7049555961..28a8ebf0eb 100644 --- a/integration/helpers/rsc-parcel/src/entry.ssr.tsx +++ b/integration/helpers/rsc-parcel/src/entry.ssr.tsx @@ -4,8 +4,8 @@ import express from "express"; // @ts-expect-error - no types import { renderToReadableStream as renderHTMLToReadableStream } from "react-dom/server.edge" assert { env: "react-client" }; import { - routeRSCServerRequest, - RSCStaticRouter, + unstable_routeRSCServerRequest as routeRSCServerRequest, + unstable_RSCStaticRouter as RSCStaticRouter, } from "react-router" assert { env: "react-client" }; // @ts-expect-error import { createFromReadableStream } from "react-server-dom-parcel/client.edge" assert { env: "react-client" }; diff --git a/integration/helpers/rsc-vite/src/entry.browser.tsx b/integration/helpers/rsc-vite/src/entry.browser.tsx index 144736bf35..498770d75f 100644 --- a/integration/helpers/rsc-vite/src/entry.browser.tsx +++ b/integration/helpers/rsc-vite/src/entry.browser.tsx @@ -11,9 +11,9 @@ import { manifest } from "virtual:react-manifest"; import { type DecodeServerResponseFunction, type EncodeActionFunction, - createCallServer, - getServerStream, - RSCHydratedRouter, + unstable_createCallServer as createCallServer, + unstable_getServerStream as getServerStream, + unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; import { type ServerPayload } from "react-router/rsc"; diff --git a/integration/helpers/rsc-vite/src/entry.rsc.tsx b/integration/helpers/rsc-vite/src/entry.rsc.tsx index 1feb2cbd50..83450bfc0b 100644 --- a/integration/helpers/rsc-vite/src/entry.rsc.tsx +++ b/integration/helpers/rsc-vite/src/entry.rsc.tsx @@ -1,7 +1,7 @@ /// import { type DecodeCallServerFunction, - matchRSCServerRequest, + unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; // @ts-expect-error - no types yet import { manifest } from "virtual:react-manifest"; diff --git a/integration/helpers/rsc-vite/src/entry.ssr.tsx b/integration/helpers/rsc-vite/src/entry.ssr.tsx index 45040b4e0d..9d65d7a6ad 100644 --- a/integration/helpers/rsc-vite/src/entry.ssr.tsx +++ b/integration/helpers/rsc-vite/src/entry.ssr.tsx @@ -7,7 +7,10 @@ import RDS from "react-dom/server.edge"; // @ts-expect-error import { bootstrapModules, manifest } from "virtual:react-manifest"; -import { routeRSCServerRequest, RSCStaticRouter } from "react-router"; +import { + unstable_routeRSCServerRequest as routeRSCServerRequest, + unstable_RSCStaticRouter as RSCStaticRouter, +} from "react-router"; type CloudflareEnv = { ASSETS: Fetcher; diff --git a/packages/react-router/dom-export.ts b/packages/react-router/dom-export.ts index 4c0d218ed4..127fc64213 100644 --- a/packages/react-router/dom-export.ts +++ b/packages/react-router/dom-export.ts @@ -1,3 +1,5 @@ +"use client"; + export type { RouterProviderProps } from "./lib/dom-export/dom-router-provider"; export { RouterProvider } from "./lib/dom-export/dom-router-provider"; export { HydratedRouter } from "./lib/dom-export/hydrated-router"; diff --git a/packages/react-router/index.ts b/packages/react-router/index.ts index 82ffea8efb..f132b46675 100644 --- a/packages/react-router/index.ts +++ b/packages/react-router/index.ts @@ -287,9 +287,15 @@ export type { DecodeServerResponseFunction, EncodeActionFunction, } from "./lib/rsc/browser"; -export { createCallServer, RSCHydratedRouter } from "./lib/rsc/browser"; -export { routeRSCServerRequest, RSCStaticRouter } from "./lib/rsc/server.ssr"; -export { getServerStream } from "./lib/rsc/html-stream/browser"; +export { + createCallServer as unstable_createCallServer, + RSCHydratedRouter as unstable_RSCHydratedRouter, +} from "./lib/rsc/browser"; +export { + routeRSCServerRequest as unstable_routeRSCServerRequest, + RSCStaticRouter as unstable_RSCStaticRouter, +} from "./lib/rsc/server.ssr"; +export { getServerStream as unstable_getServerStream } from "./lib/rsc/html-stream/browser"; /////////////////////////////////////////////////////////////////////////////// // DANGER! PLEASE READ ME! diff --git a/packages/react-router/rsc-export.ts b/packages/react-router/rsc-export.ts index 794ac3c72d..a1e437a57c 100644 --- a/packages/react-router/rsc-export.ts +++ b/packages/react-router/rsc-export.ts @@ -50,4 +50,4 @@ export type { ServerRouteMatch, ServerRouteObject, } from "./lib/rsc/server.rsc"; -export { matchRSCServerRequest } from "./lib/rsc/server.rsc"; +export { matchRSCServerRequest as unstable_matchRSCServerRequest } from "./lib/rsc/server.rsc"; diff --git a/playground/rsc-parcel/src/entry.browser.tsx b/playground/rsc-parcel/src/entry.browser.tsx index 2f412c8596..a8b854a4e2 100644 --- a/playground/rsc-parcel/src/entry.browser.tsx +++ b/playground/rsc-parcel/src/entry.browser.tsx @@ -3,9 +3,9 @@ import * as React from "react"; import { hydrateRoot } from "react-dom/client"; import { - createCallServer, - getServerStream, - RSCHydratedRouter, + unstable_createCallServer as createCallServer, + unstable_getServerStream as getServerStream, + unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; import type { ServerPayload } from "react-router/rsc"; import { diff --git a/playground/rsc-parcel/src/entry.rsc.ts b/playground/rsc-parcel/src/entry.rsc.ts index 9080e93ebc..f23166fd39 100644 --- a/playground/rsc-parcel/src/entry.rsc.ts +++ b/playground/rsc-parcel/src/entry.rsc.ts @@ -10,7 +10,7 @@ import { import { type DecodeCallServerFunction, type DecodeFormActionFunction, - matchRSCServerRequest, + unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; import { routes } from "./routes"; diff --git a/playground/rsc-parcel/src/entry.ssr.tsx b/playground/rsc-parcel/src/entry.ssr.tsx index 55df1059aa..a62548e714 100644 --- a/playground/rsc-parcel/src/entry.ssr.tsx +++ b/playground/rsc-parcel/src/entry.ssr.tsx @@ -3,8 +3,8 @@ import express from "express"; // @ts-expect-error - no types import { renderToReadableStream as renderHTMLToReadableStream } from "react-dom/server.edge" assert { env: "react-client" }; import { - routeRSCServerRequest, - RSCStaticRouter, + unstable_routeRSCServerRequest as routeRSCServerRequest, + unstable_RSCStaticRouter as RSCStaticRouter, } from "react-router" assert { env: "react-client" }; // @ts-expect-error import { createFromReadableStream } from "react-server-dom-parcel/client.edge" assert { env: "react-client" }; diff --git a/playground/rsc-vite/src/browser/entry.browser.tsx b/playground/rsc-vite/src/browser/entry.browser.tsx index 144736bf35..498770d75f 100644 --- a/playground/rsc-vite/src/browser/entry.browser.tsx +++ b/playground/rsc-vite/src/browser/entry.browser.tsx @@ -11,9 +11,9 @@ import { manifest } from "virtual:react-manifest"; import { type DecodeServerResponseFunction, type EncodeActionFunction, - createCallServer, - getServerStream, - RSCHydratedRouter, + unstable_createCallServer as createCallServer, + unstable_getServerStream as getServerStream, + unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; import { type ServerPayload } from "react-router/rsc"; diff --git a/playground/rsc-vite/src/rsc/entry.rsc.tsx b/playground/rsc-vite/src/rsc/entry.rsc.tsx index 542f65ac02..5069916b63 100644 --- a/playground/rsc-vite/src/rsc/entry.rsc.tsx +++ b/playground/rsc-vite/src/rsc/entry.rsc.tsx @@ -6,7 +6,7 @@ import { manifest } from "virtual:react-manifest"; import { type DecodeCallServerFunction, - matchRSCServerRequest, + unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; import { routes } from "../routes"; diff --git a/playground/rsc-vite/src/ssr/entry.ssr.tsx b/playground/rsc-vite/src/ssr/entry.ssr.tsx index 45040b4e0d..9d65d7a6ad 100644 --- a/playground/rsc-vite/src/ssr/entry.ssr.tsx +++ b/playground/rsc-vite/src/ssr/entry.ssr.tsx @@ -7,7 +7,10 @@ import RDS from "react-dom/server.edge"; // @ts-expect-error import { bootstrapModules, manifest } from "virtual:react-manifest"; -import { routeRSCServerRequest, RSCStaticRouter } from "react-router"; +import { + unstable_routeRSCServerRequest as routeRSCServerRequest, + unstable_RSCStaticRouter as RSCStaticRouter, +} from "react-router"; type CloudflareEnv = { ASSETS: Fetcher; From 819ae2def64fad934059b83f6b3abf2ca402812f Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Tue, 27 May 2025 13:30:11 -0700 Subject: [PATCH 2/2] mark types unstable as well --- .../helpers/rsc-parcel/src/entry.browser.tsx | 2 +- integration/helpers/rsc-parcel/src/entry.rsc.ts | 4 ++-- integration/helpers/rsc-parcel/src/routes.ts | 2 +- .../helpers/rsc-vite/src/entry.browser.tsx | 6 +++--- integration/helpers/rsc-vite/src/entry.rsc.tsx | 2 +- integration/helpers/rsc-vite/src/routes.ts | 2 +- integration/rsc/rsc-test.ts | 4 ++-- packages/react-router/index.ts | 4 ++-- packages/react-router/rsc-export.ts | 16 ++++++++-------- playground/rsc-parcel/src/entry.browser.tsx | 2 +- playground/rsc-parcel/src/entry.rsc.ts | 4 ++-- playground/rsc-parcel/src/routes.ts | 2 +- .../rsc-vite/src/browser/entry.browser.tsx | 6 +++--- playground/rsc-vite/src/routes.ts | 2 +- playground/rsc-vite/src/rsc/entry.rsc.tsx | 2 +- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/integration/helpers/rsc-parcel/src/entry.browser.tsx b/integration/helpers/rsc-parcel/src/entry.browser.tsx index a8b854a4e2..af2621c657 100644 --- a/integration/helpers/rsc-parcel/src/entry.browser.tsx +++ b/integration/helpers/rsc-parcel/src/entry.browser.tsx @@ -7,7 +7,7 @@ import { unstable_getServerStream as getServerStream, unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; -import type { ServerPayload } from "react-router/rsc"; +import type { unstable_ServerPayload as ServerPayload } from "react-router/rsc"; import { createFromReadableStream, encodeReply, diff --git a/integration/helpers/rsc-parcel/src/entry.rsc.ts b/integration/helpers/rsc-parcel/src/entry.rsc.ts index e786fbb53a..6e52b6a682 100644 --- a/integration/helpers/rsc-parcel/src/entry.rsc.ts +++ b/integration/helpers/rsc-parcel/src/entry.rsc.ts @@ -8,8 +8,8 @@ import { // @ts-expect-error } from "react-server-dom-parcel/server.edge"; import { - type DecodeCallServerFunction, - type DecodeFormActionFunction, + type unstable_DecodeCallServerFunction as DecodeCallServerFunction, + type unstable_DecodeFormActionFunction as DecodeFormActionFunction, unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; diff --git a/integration/helpers/rsc-parcel/src/routes.ts b/integration/helpers/rsc-parcel/src/routes.ts index 6cc7b2a7bd..d29bd3aca2 100644 --- a/integration/helpers/rsc-parcel/src/routes.ts +++ b/integration/helpers/rsc-parcel/src/routes.ts @@ -1,4 +1,4 @@ -import type { ServerRouteObject } from "react-router/rsc"; +import type { unstable_ServerRouteObject as ServerRouteObject } from "react-router/rsc"; export const routes = [ { diff --git a/integration/helpers/rsc-vite/src/entry.browser.tsx b/integration/helpers/rsc-vite/src/entry.browser.tsx index 498770d75f..b48deb805c 100644 --- a/integration/helpers/rsc-vite/src/entry.browser.tsx +++ b/integration/helpers/rsc-vite/src/entry.browser.tsx @@ -9,13 +9,13 @@ import { import { manifest } from "virtual:react-manifest"; import { - type DecodeServerResponseFunction, - type EncodeActionFunction, + type unstable_DecodeServerResponseFunction as DecodeServerResponseFunction, + type unstable_EncodeActionFunction as EncodeActionFunction, unstable_createCallServer as createCallServer, unstable_getServerStream as getServerStream, unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; -import { type ServerPayload } from "react-router/rsc"; +import { type unstable_ServerPayload as ServerPayload } from "react-router/rsc"; const encodeAction: EncodeActionFunction = (args: unknown[]) => encodeReply(args); diff --git a/integration/helpers/rsc-vite/src/entry.rsc.tsx b/integration/helpers/rsc-vite/src/entry.rsc.tsx index 83450bfc0b..41945dd987 100644 --- a/integration/helpers/rsc-vite/src/entry.rsc.tsx +++ b/integration/helpers/rsc-vite/src/entry.rsc.tsx @@ -1,6 +1,6 @@ /// import { - type DecodeCallServerFunction, + type unstable_DecodeCallServerFunction as DecodeCallServerFunction, unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; // @ts-expect-error - no types yet diff --git a/integration/helpers/rsc-vite/src/routes.ts b/integration/helpers/rsc-vite/src/routes.ts index 6cc7b2a7bd..d29bd3aca2 100644 --- a/integration/helpers/rsc-vite/src/routes.ts +++ b/integration/helpers/rsc-vite/src/routes.ts @@ -1,4 +1,4 @@ -import type { ServerRouteObject } from "react-router/rsc"; +import type { unstable_ServerRouteObject as ServerRouteObject } from "react-router/rsc"; export const routes = [ { diff --git a/integration/rsc/rsc-test.ts b/integration/rsc/rsc-test.ts index 6743ba70a3..b791c9a083 100644 --- a/integration/rsc/rsc-test.ts +++ b/integration/rsc/rsc-test.ts @@ -207,7 +207,7 @@ implementations.forEach((implementation) => { port, files: { "src/routes.ts": js` - import type { ServerRouteObject } from "react-router/rsc"; + import type { unstable_ServerRouteObject as ServerRouteObject } from "react-router/rsc"; export const routes = [ { @@ -338,7 +338,7 @@ implementations.forEach((implementation) => { port, files: { "src/routes.ts": js` - import type { ServerRouteObject } from "react-router/rsc"; + import type { unstable_ServerRouteObject as ServerRouteObject } from "react-router/rsc"; export const routes = [ { diff --git a/packages/react-router/index.ts b/packages/react-router/index.ts index f132b46675..e4fe91afa7 100644 --- a/packages/react-router/index.ts +++ b/packages/react-router/index.ts @@ -284,8 +284,8 @@ export { href } from "./lib/href"; // RSC export type { - DecodeServerResponseFunction, - EncodeActionFunction, + DecodeServerResponseFunction as unstable_DecodeServerResponseFunction, + EncodeActionFunction as unstable_EncodeActionFunction, } from "./lib/rsc/browser"; export { createCallServer as unstable_createCallServer, diff --git a/packages/react-router/rsc-export.ts b/packages/react-router/rsc-export.ts index a1e437a57c..b1b3c5b4d0 100644 --- a/packages/react-router/rsc-export.ts +++ b/packages/react-router/rsc-export.ts @@ -40,14 +40,14 @@ export { createCookieSessionStorage } from "./lib/server-runtime/sessions/cookie export { createMemorySessionStorage } from "./lib/server-runtime/sessions/memoryStorage"; export type { - DecodeCallServerFunction, - DecodeFormActionFunction, - ServerManifestPayload, - ServerMatch, - ServerPayload, - ServerRenderPayload, + DecodeCallServerFunction as unstable_DecodeCallServerFunction, + DecodeFormActionFunction as unstable_DecodeFormActionFunction, + ServerManifestPayload as unstable_ServerManifestPayload, + ServerMatch as unstable_ServerMatch, + ServerPayload as unstable_ServerPayload, + ServerRenderPayload as unstable_ServerRenderPayload, RenderedRoute as ServerRouteManifest, - ServerRouteMatch, - ServerRouteObject, + ServerRouteMatch as unstable_ServerRouteMatch, + ServerRouteObject as unstable_ServerRouteObject, } from "./lib/rsc/server.rsc"; export { matchRSCServerRequest as unstable_matchRSCServerRequest } from "./lib/rsc/server.rsc"; diff --git a/playground/rsc-parcel/src/entry.browser.tsx b/playground/rsc-parcel/src/entry.browser.tsx index a8b854a4e2..af2621c657 100644 --- a/playground/rsc-parcel/src/entry.browser.tsx +++ b/playground/rsc-parcel/src/entry.browser.tsx @@ -7,7 +7,7 @@ import { unstable_getServerStream as getServerStream, unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; -import type { ServerPayload } from "react-router/rsc"; +import type { unstable_ServerPayload as ServerPayload } from "react-router/rsc"; import { createFromReadableStream, encodeReply, diff --git a/playground/rsc-parcel/src/entry.rsc.ts b/playground/rsc-parcel/src/entry.rsc.ts index f23166fd39..eb78176690 100644 --- a/playground/rsc-parcel/src/entry.rsc.ts +++ b/playground/rsc-parcel/src/entry.rsc.ts @@ -8,8 +8,8 @@ import { // @ts-expect-error } from "react-server-dom-parcel/server.edge"; import { - type DecodeCallServerFunction, - type DecodeFormActionFunction, + type unstable_DecodeCallServerFunction as DecodeCallServerFunction, + type unstable_DecodeFormActionFunction as DecodeFormActionFunction, unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc"; diff --git a/playground/rsc-parcel/src/routes.ts b/playground/rsc-parcel/src/routes.ts index 3afe40bbe3..4c033dda4d 100644 --- a/playground/rsc-parcel/src/routes.ts +++ b/playground/rsc-parcel/src/routes.ts @@ -1,4 +1,4 @@ -import type { ServerRouteObject } from "react-router/rsc"; +import type { unstable_ServerRouteObject as ServerRouteObject } from "react-router/rsc"; export const routes = [ { diff --git a/playground/rsc-vite/src/browser/entry.browser.tsx b/playground/rsc-vite/src/browser/entry.browser.tsx index 498770d75f..9d2d0f6055 100644 --- a/playground/rsc-vite/src/browser/entry.browser.tsx +++ b/playground/rsc-vite/src/browser/entry.browser.tsx @@ -9,13 +9,13 @@ import { import { manifest } from "virtual:react-manifest"; import { - type DecodeServerResponseFunction, - type EncodeActionFunction, + type unstable_DecodeServerResponseFunction as DecodeServerResponseFunction, + type unstable_EncodeActionFunction as EncodeActionFunction, unstable_createCallServer as createCallServer, unstable_getServerStream as getServerStream, unstable_RSCHydratedRouter as RSCHydratedRouter, } from "react-router"; -import { type ServerPayload } from "react-router/rsc"; +import type { unstable_ServerPayload as ServerPayload } from "react-router/rsc"; const encodeAction: EncodeActionFunction = (args: unknown[]) => encodeReply(args); diff --git a/playground/rsc-vite/src/routes.ts b/playground/rsc-vite/src/routes.ts index c54a332be4..d491f8749b 100644 --- a/playground/rsc-vite/src/routes.ts +++ b/playground/rsc-vite/src/routes.ts @@ -1,4 +1,4 @@ -import type { ServerRouteObject } from "react-router/rsc"; +import type { unstable_ServerRouteObject as ServerRouteObject } from "react-router/rsc"; export const routes = [ { diff --git a/playground/rsc-vite/src/rsc/entry.rsc.tsx b/playground/rsc-vite/src/rsc/entry.rsc.tsx index 5069916b63..6946382d1b 100644 --- a/playground/rsc-vite/src/rsc/entry.rsc.tsx +++ b/playground/rsc-vite/src/rsc/entry.rsc.tsx @@ -5,7 +5,7 @@ import { decodeReply, renderToReadableStream } from "../../framework/server"; import { manifest } from "virtual:react-manifest"; import { - type DecodeCallServerFunction, + type unstable_DecodeCallServerFunction as DecodeCallServerFunction, unstable_matchRSCServerRequest as matchRSCServerRequest, } from "react-router/rsc";