Server Actions
The Memberstack Nextjs package comes with server side actions that you can use instead of the admin package that use fetch so you can take advantage of the nextjs cache mechanism
You can initialize the Memberstack class singleton with your memberstack api key
Which then returns an object with the following async functions:
getApp()
getApp()
API
Arguments
None
Returns
getUser()
getUser()
API
Arguments
None
Returns
getPlans()
getPlans()
API
Arguments
None
Returns
getPlan({planId})
signupWithPassword({email, password, customFields, metaData, captchaToken, plans})
signupPasswordless({email, customFields, passwordlessToken, metaData, captchaToken, plans})
loginWithPassword({email, password})
loginPasswordless({email, passworldlessToken})
logout()
sendVerificationEmail()
sendResetPasswordEmail({email})
resetPassword({token, newPassword})
createCheckoutUrl({priceId, couponId, cancelUrl, successUrl})
createCustomerPortal({priceIds, configuration, returnUrl})
updateMemberAuth({email, oldPassword, newPassword})
updateMemberCustomField({customFields})
Notes:
The useCookie
flag is automatically set to true by default when initializing memberstack in the react and nextjs package. The name for for the cookie is _ms-mid
and is passed to each fetch call action.
Last updated