diff --git a/docs/src/pages/en/(pages)/features/micro-frontends.mdx b/docs/src/pages/en/(pages)/features/micro-frontends.mdx index fd38f9b0..5d215f18 100644 --- a/docs/src/pages/en/(pages)/features/micro-frontends.mdx +++ b/docs/src/pages/en/(pages)/features/micro-frontends.mdx @@ -255,4 +255,25 @@ To run the example, clone the `@lazarv/react-server` repository and run the foll ```sh pnpm install pnpm --filter ./examples/remote dev -``` \ No newline at end of file +``` + + +## Disabling Remote Components rendering + + +Applications that don't host Remote Components can force-disable the entire rendering path by setting `remoteComponents: false` in the runtime config. The runtime then ignores the `@__react_server_remote__` URL marker, never enters the Remote Components code path, and never parses request bodies as Remote Components payloads. + +```js +// react-server.config.mjs +export default { + remoteComponents: false, +}; +``` + +Two effects worth understanding: + +The remote-rendering routing is removed. URLs carrying the `@__react_server_remote__` marker are no longer treated as Remote Components fetches; they fall through to normal page rendering as if the marker weren't there. + +Temporary references — the runtime mechanism that lets non-serializable client values (callbacks, DOM refs, opaque thenables) round-trip through `$T` tags on the wire — are gated by the same flag. Their only legitimate use is round-tripping values back to the same client during a Remote Components render, so when `remoteComponents: false` is set, the temporary-reference set is not created and any `$T` tag in an incoming request body is rejected as malformed. This eliminates a small but real attack surface: a fabricated body otherwise allocates proxy objects and runs opaque lookups against the in-memory reference map. + +This pairs with `serverFunctions: false` (see [Disabling Server Functions entirely](../guide/server-functions#disabling-server-functions)) for apps that want to ship a strictly read-only surface — neither Server Functions nor Remote Components remain reachable, and any `POST`/`PUT`/`PATCH`/`DELETE` traffic flows through to normal rendering without parsing the request body. \ No newline at end of file diff --git a/docs/src/pages/en/(pages)/guide/server-functions.mdx b/docs/src/pages/en/(pages)/guide/server-functions.mdx index 190bf6bd..576c4d48 100644 --- a/docs/src/pages/en/(pages)/guide/server-functions.mdx +++ b/docs/src/pages/en/(pages)/guide/server-functions.mdx @@ -1,29 +1,29 @@ --- -title: Server functions +title: Server Functions order: 4 --- import Link from "../../../../components/Link.jsx"; -# Server functions +# Server Functions -Server functions are async functions that can be called from the client-side. You don't have to implement API endpoints for these functions to be callable as the client can call these functions like a direct reference to the function itself. Server functions are usable on forms, buttons, submit inputs, and as props to client components. React and the runtime will manage calling these functions on the server-side. +Server Functions are async functions that can be called from the client-side. You don't have to implement API endpoints for these functions to be callable as the client can call these functions like a direct reference to the function itself. Server Functions are usable on forms, buttons, submit inputs, and as props to client components. React and the runtime will manage calling these functions on the server-side. -You can expose any `"use server";` marked function as a server function. Server functions can be called from the client using the `action` prop on a `