Skip to content

[Enhancement] Add option to prevent fallback to client-side execution when using use() #34349

@vuthanhtrung2010

Description

@vuthanhtrung2010

Note: SORRY IF I CREATED USING BUG REPORT TEMPLATE, PLEASE CORRECT ME THE TEMPLATE I SHOULD USE IF I AM WRONG, because I can't find a template named "Feature Request" :(((

Issue Type: Enhancement / Feature Request

Currently, when using use() in React server components, if a server-side action fails or is unavailable, it may fall back to executing on the client side. I propose adding a parameter or option that allows developers to disallow this fallback, ensuring that certain actions always remain server-only.

This would be useful in scenarios where:

  • Sensitive operations must never execute on the client.
  • Server-specific resources or data are required.
  • Consistency and security need to be enforced.

Proposed Behavior:

  • Add a boolean parameter (e.g., allowClientFallback = true) to use().
  • When set to false, use() should throw an error if the server action is unavailable, instead of falling back to client-side execution.

Example:

const data = use(fetchServerData, { allowClientFallback: false });

Benefits:

  • Prevent accidental execution of server-only logic on the client.
  • Improve security and predictability of server components.
  • Give developers explicit control over fallback behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions