Next.js Discord

Discord Forum

Maintaining auth and subscription status across components

Unanswered
Beveren posted this in #help-forum
Open in Discord
BeverenOP
Bit of a noob question here. I'm building a subscription saas with auth from supabase, and referencing many examples including the nextjs subscriptions project.

I'm maintaining the user session by constantly calling supabase.auth.getSession in various places as needed (as I understand this is not an expensive operation).

I also want to reference/maintain the status of their subscription, which I can retrieve via stripe JS, OR via supabase stored data.

I'm having trouble understanding when to use something like an AuthProvider that wraps the main layout across my app, vs a context, using constantly just calling the getSession or getSubscription functions that I need, when and where I need them.

I'm still researching various details but would appreciate any clarifications where I am misunderstanding or poiting me to any other good examples of this. Thank you

0 Replies