Skip to content

Split client and server transporters #13158

Open
@cooolbros

Description

@cooolbros

Describe the problem

The transport hook added in 2.11.0 is insufficient for returning long lived variables from load functions, such as ReadableStreams/async iterators and Observables

Describe the proposed solution

Split the transport encode/decode into hooks.server.js and hooks.client.js to allow for long lived variables to be serialized into IDs by the user, then revived on the client using an SSE or Websocket connection, similar to how Promises are already serialized into unique IDs that are attached to the window and resolved later.

Ideally this should also not leak the server implementation to the client

Alternatives considered

You can return an ID from a load function, then set up the SSE connection from the client, but this is brittle and not reusable

Importance

nice to have

Additional Information

Feature announcement: https://bsky.app/profile/svelte.dev/post/3ld4ncjryfs2g

Feature PR: #13149
PR that would fix this: #13125

Similar to: #13156

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions