Heath
Heath5mo ago

Setting non-auth client context

Is it possible to set some kind of arbitrary client context that is accessible from all functions, similar to ctx.auth? Something I can specify once on the client side, without having to pass it constantly to every function. Or even literally using the ctx.auth and related features, but without a 3rd party identity provider, just as a vehicle to communicate some client state.
3 Replies
Michal Srb
Michal Srb5mo ago
The best way right now is to create a wrapper for useQuery et. al and similarly for query et. al on the server. Check out: https://stack.convex.dev/anonymous-users-via-sessions
Anonymous Users via Sessions
Getting users to sign up for a new service before seeing any benefits is challenging. In this post, we looked at a couple of strategies for managing u...
Heath
HeathOP5mo ago
Thanks, @Michal Srb !
Heath
HeathOP5mo ago
*(for anybody else who may find this q) * That article was informative and I will spend some time with the sample code. It also links to the following article which is extremely relevant to what we're doing, and provides a lot of valuable guidance: https://stack.convex.dev/track-sessions-without-cookies
Session Tracking Without Cookies
Advice and resources for session tracking per-tab or per-browser via localStorage / sessionStorage using React Context, hooks, and some utilities to m...

Did you find this page helpful?