How can I get user current plan in opensaas template
How can I get user current plan in opensaas template ?
3 Replies
Hi @2euxs. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To get the user's current plan in the OpenSaaS template, you can access the user object which contains information about their subscription status. Here's how you can do it:
1. On the client-side:
You can use the
useAuth
hook or the user
prop (if authRequired
is set to true
for the page) to access the user object. The user object will contain fields related to the subscription status.
Wasp Docs - Accessing the logged-in user (https://wasp-lang.dev/docs/auth/overview#on-the-client)
2. On the server-side:
In your actions or queries, you can access the user object through the context
parameter. The user object will contain the same subscription-related fields.
The exact fields you'll use to determine the current plan may vary depending on how the OpenSaaS template is set up, but typically you'll want to look at subscriptionStatus
and subscriptionTier
(or similar fields) on the user object.
Keep in mind that the specific implementation might differ slightly based on the version of the OpenSaaS template you're using. If you're having trouble finding these fields, you may need to check the User entity definition in your Wasp file to see exactly how the subscription information is stored.
Discord - OpenSaaS subscription status discussion (https://discord.com/channels/686873244791210014/1214979650803998781)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @2euxs, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Hey @2euxs did that answer your question?
Yes thank you