supertokens / supertokens-auth-react

ReactJS authentication module for SuperTokens
https://supertokens.com
Other
276 stars 84 forks source link

Update Needed: SuperTokens Compatibility with Next.js 14 (App Router) #769

Closed bukandicki closed 10 months ago

bukandicki commented 10 months ago

Hey! I tried following the example on https://github.com/supertokens/next.js/tree/canary/examples/with-supertokens using Next.js 14, and I ran into an issue. Could you please let me know which component should I add to use the client at the top?

I'm really excited to figure this out and appreciate your help!

image

After clicking the Google button, things took a bit of a detour with some unexpected errors. Any ideas on how to fix this

 ⨯ node_modules/supertokens-auth-react/lib/build/translationContext.js (16:48) @ createContext
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
rishabhpoddar commented 10 months ago

So i tried the following steps, and it works:

It works as expected. Could you try these steps?

bukandicki commented 10 months ago

So i tried the following steps, and it works:

  • Download the demo app. I selected nextjs, app dir, emailpassword + social login
npx create-supertokens-app@latest
  • Navigate to the generated app, and edit the package.json to use "next": "^14.0.0", in the dependencies.
  • Reinstalled node modules in the root of the demo app
  • Switched to node 18
  • Ran npm run dev

It works as expected. Could you try these steps?

Thank you! @rishabhpoddar I followed the steps you provided, and it's working as expected. I appreciate your help! 🎉