Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning Uint8Array / Buffer from +page.server.ts load(). #10416

Closed
Palmik opened this issue Jul 21, 2023 · 3 comments
Closed

Returning Uint8Array / Buffer from +page.server.ts load(). #10416

Palmik opened this issue Jul 21, 2023 · 3 comments

Comments

@Palmik
Copy link

Palmik commented Jul 21, 2023

Describe the problem

Currently if you want to return binary data to the client you need to manually encode and decode the data using e.g. base64. This is cumbersome and error prone.

You run into this when using e.g. gRPC or when trying to return some file.

Describe the proposed solution

It would be great to have native support for binary responses. This might also open doors for custom serialization formats -- I would love to have my load function return a protobuf, and transparently receive it on the client in PageData, in a type safe manner.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@ghostdevv
Copy link
Member

The problem usually is if we start specifically going out of the way to support one framework/data type then we have to support others. Specifically for things like Uint8Array an issue would be better put in devalue as that's where the serialisation is coming from

@Palmik
Copy link
Author

Palmik commented Jul 28, 2023

I agree that the support should not be framework specific. Uint8Array is a basic primitive.

@LorisSigrist
Copy link
Contributor

I submitted a Pull Request to devalue that would add support for Typed Arrays (like Uint8Array) and Arraybuffers. Let's see if it gets merged

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

No branches or pull requests

4 participants