clerk / use-stripe-subscription

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Nextjs App Router?

tillka opened this issue · comments

commented

Hi,

I found this package as it is 100% what I need to connect my app with stripe and clerk.
I tried to follow the demo but it is using the old /pages router. With my limited knowledge, I tried to re-factor it but failed in the end, as the SubscriptionProvider is using createContext - which is only possible in Client Components not Server Components.

Before I try to find another solution, are you thinking of refactoring this package to use the new app router?

Best

Till

+1 for this issue @colinclerk

Same!
following this

my solution was to create a layout with SubscriptionProvider inside the children app folders, only the ones that needs SubscriptionProvider`, to know if user is subscribed.

Also I can use 'use client'; for those layouts (not the case for the root layout that's the trick)
Probably not optimal if you want to know for all the pages, bug it should work