vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
6.23k stars 1.27k forks source link

Add gated content pages that render based on Subscription tiers 🙏💚💚💚 #119

Closed andriusmv closed 1 year ago

andriusmv commented 2 years ago

Add gated content pages (or components) that render based on Subscription tiers 🙏💚💚💚

Exhibit best practices for conditional rendering of pages (or components) based on subscription tiers -already set up in this demo (Hobby, Freelancer, Startup and Enterprise for example)-.

Two options seem possible for such conditional rendering of elements:

  1. Avoiding redirection: all users access a specific page but with different views. membershipType == "Hobby" ? <HobbyComponent/> : <PleaseUpgradeComponent/> or similar.
  2. Using a high-level component: using useEffect for accessing specific pages based on subscription tier (redirect URL). membership type == "Gold" and redirect to whatever URL you want.

🚀🚀🚀

leerob commented 1 year ago

Great suggestion! This would be awesome to see. We don't have any plans to update this currently, but open to reviewing PRs if someone adds something for this.