[Flight] Server References for arbitrary object types (#37636)
GitHub Commits - Example: React

[Flight] Server References for arbitrary object types (#37636)

Experimental Flag

  • Added behind a new experimental flag, enableFlightObjectReferences.

Extended Server References

  • Extends Server References so that a reference can point to an object, not just a function.

New Registration API

  • An object is registered with a new API, registerServerObjectReference, which tags it with its module id the same way registerServerReference tags a Server Function.

Client Handling

  • The client receives an opaque handle: reading a property or calling it throws, similar to how Temporary References work inside Server Functions.
  • The only thing the client can do with the handle is pass it back to the server via a Server Function, where it resolves through the server manifest.

Use Case: Requestโ€‘Scoped Values

  • The motivating use case is letting a framework pass requestโ€‘scoped values by reference, so it can omit them from the request body.
  • Example: a framework could model searchParams as a module export whose value resolves from the current request.
  • Benefits: avoids encoding the search params twice (they already appear in the request URL) and makes responses more cacheable: if the search params don't appear elsewhere in the body, a response cache can omit them from its cache key.

Implementation Scope

  • This initial PR only exposes the new API in the Turbopack bindings.
  • We will port it to the other bundler configs if the experiment advances.

Issue Details

  • [#37636]
  • 0 commit comments

Comments

No comments yet. Start the discussion.