Skip to content

fix(plugin-rsc): expose encodeFormAction option type and re-export encodeReply from ssr#1280

Open
dai-shi wants to merge 1 commit into
vitejs:mainfrom
dai-shi:fix/plugin-rsc
Open

fix(plugin-rsc): expose encodeFormAction option type and re-export encodeReply from ssr#1280
dai-shi wants to merge 1 commit into
vitejs:mainfrom
dai-shi:fix/plugin-rsc

Conversation

@dai-shi

@dai-shi dai-shi commented Jul 11, 2026

Copy link
Copy Markdown

Two gaps hit when a framework customizes React's progressive-enhancement
form encoding during SSR. The first is required for wakujs/waku's pending
change; the second is a type-only convenience.

  1. Missing export (blocking). A custom encodeFormAction that reproduces
    React's default $ACTION_REF_ field encoding needs encodeReply, which
    the vendored client.edge exports but the /ssr (and /react/ssr)
    wrappers do not re-export. Importing it from /ssr, the same entry that
    provides createFromReadableStream, guarantees the serializer matches
    the flight-client instance in use regardless of which react-server-dom
    build or version is active, and avoids downstream deep imports into
    vendor/. One-line re-export:

    // react/ssr.ts and ssr.ts
    export { encodeReply } from './vendor-or-resolved-client-edge';
  2. Type gap. createFromReadableStream from @vitejs/plugin-rsc/ssr
    spreads ...options into the vendored flight client, so
    encodeFormAction works at runtime today, but the published options type
    (CreateFromReadableStreamEdgeOptions) omits it, forcing a cast:

    export type CreateFromReadableStreamEdgeOptions = {
      nonce?: string;
      // add:
      encodeFormAction?: (
        actionId: string,
        boundPromise: Promise<unknown[]>,
      ) => ReactCustomFormAction;
    };

@dai-shi

dai-shi commented Jul 11, 2026

Copy link
Copy Markdown
Author

Can anyone trigger preview please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant