Trpc return stream
Hey,
I'm generating pdf doc then converting it to stream and i want to return it from my endpoint, but trpc i yelling at me with this error trpc doesn't allow to return streams? I wasn't able to find anything to clarify this in their docs or google.
2 Replies
tRPC has no native support for streams, as it can't serialize it into JSON. I'd suggest looking at https://trpc.io/docs/server/data-transformers for how to implement your own transformer or seperating each message in your stream as serializing in as JSON
Data Transformers | tRPC
You are able to serialize the response data & input args. The transformers need to be added both to the server and the client.
thx 🙂