non serializable objects in Route Context
I have an API client that is required on the client and on the server. All examples I see for tanstack just initializes these things in a global way, but that doesn't work when you need to pass arguments.
I have a few config variables that I fetch from the server and with that I can initialize the client.
I do this in the root route beforeLoad
Now any route can use that client like so:
Now I wanna use that in component.
Problem is this won't work, because $contentApi is no longer the real client, it has been serialized/deserialized I think.
(intermediate value)().queryOptions is not a functionMy hack around this currently is re-creating the api client in a context and using the context in the component instead. But loaders now use the route context and components need to use the context, that's odd to me. Is there a better way?
1 Reply
exotic-emerald•2mo ago
we will be adding a way to opt out of serialization and then rerun it on the client