T
TanStack8mo ago
ambitious-aqua

Shared Context with functions between Server and Client

Is it possible to share an object with functions or a class instance via Context between Server and Client? This seems to working for a queryClient through routerWithQueryClient but I guess there is some magic happening around serialization and reinstantiation on the client? The Router docs describe dependency injection as follows:
Dependency Injection You can supply dependencies (e.g. a loader function, a data fetching client, a mutation service) which the route and all child routes can access and use without importing or creating directly.
https://tanstack.com/router/latest/docs/framework/react/guide/router-context#how-about-using-react-contexthooks Maybe this should be clarified, if its limited to serialized contexts when switching boundaries? Also it would be nice to have separated types for contexts for server and client?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?