Next.js Discord

Discord Forum

Server side nextauth session update

Unanswered
Least Tern posted this in #help-forum
Open in Discord
Least TernOP
Is there any possible way to update session within server side component. Im trying to update subscription within the user when he either buys new one or changes the plan from basic to premium and reverse

11 Replies

Least TernOP
i want to update the data on client side instantly when customer subscribes to a specific plan but i dont want to make 50 api calls to the subscription page on every single page where it is needed
@Double-striped Thick-knee you can't set cookies or headers but you can change things in the database
Least TernOP
do you think i should just make those calls and call it a day or there is a better approach of handling live subscriptions
Least TernOP
theres only useSession which is client based
i need server based because i have a webhook for subscription variants which update the user
@Double-striped Thick-knee can't you use serverAction or api routes to update session?
Least TernOP
whenever the subscription is successful it must update the user then somehow update the session
@Double-striped Thick-knee are you using JWT?
Least TernOP
im using jwt with nextauth so yes
@Least Tern do you think i should just make those calls and call it a day or there is a better approach of handling live subscriptions
Double-striped Thick-knee
can't think of any better approach while keeping it stateless. cons of JWT I assume.
@Double-striped Thick-knee can't think of any better approach while keeping it stateless. cons of JWT I assume.
Least TernOP
I think the best solution is to constantly get subscription info everytime i need it