Creating a guest user session

Hey there! So I’m looking to add a feature to my app that allows the user to use some of the auth-only areas as a “guest” user, something like Railway’s 24 hour guest session.

I come from Rails, and over there I’d do something like drop a Concern into AppController and have it handle creating the guest account if the user is not logged in, and some sign up logic that converts their guest account to a full user account.

What I’m not sure of is how to do this with React & Redwood. I’m using Clerk for Auth, and I’ve got that working just fine to get actual user sessions, but I’m a little stumped on where to tie into the react lifecycle to get my Guest user setup.

What I’m trying to do is something like, if they’re not authed or have a guest account, then I want to call the API endpoint to construct the guest account, then store that in the session so I can track them, and upgrade to the guest to a real account once they have a Clerk user to tie it against.

On the DB Side there’s an Account model that will track all of this and tie into billing eventually.

So is this something I want to do in App.js with my own provider? Or would the best place be to try and tie into it in web/src/auth and/or api/src/lib/auth? Or is there an easier way to hook into the auth lifecycle that I’m not aware of? Coming from Rails, my logic feels completely upside down to how Redwood/React works.

Any help is greatly appreciated!

So doing some digging, it seems like at least with Clerk, I can handle some of this through their useSignUp hook to manage the “guest” aspect until further into the app where they finish sign up, but still not sure on the best way to handle creating the Account record on my end in the first place.