Trying to get the user session in server side Next.js v14 pages directory, always returns null
I'm pretty sure I might have screwed something up in the setup, but the docs for setting up the provider for pages directory still show an app directory layout, has anyone set it up succesfully for Next.js pages directory v14?
10 Replies
The client side works properly, shows proper authentication status and user data
but returns null in the server side
can you provide an example
I'm no kinde staff, but actively working with kinde in next.js 14 app router version, so might be able to help
hey, so I'm not used to the app router, was building with the pages router, hence just wanted to set it up
should I give in to the app router, or try to make it work with pages router
Kinde Docs
NextJS Pages Router SDK v2 - Developer tools - Help center
Our developer tools provide everything you need to get started with Kinde.
This seems to be the SDK for your setup. Here it says they recommend going for the app router
yeah, I think I need to set up the layout separately in an app directory even if using pages directory
How are you calling kinde on server side?
I assume you do this in getServerSideProps for example, since it's next.js pages router
Here is an example from the doc:
also, check that your imports are correct, my autoimporter somehow didn't recognize the right paths, I had to manually type in the imports
hey thanks a lot for your help and time, I had to move quick so decided to go with moving everything to app router :/
Hey @Kunal Bagaria,
@gooby.wooby is right, we recommend NextJS App Router, but of course we can help you out if you are using Pages Router.
Sounds like you have gone ahead and implemented NextJS App Router.
Please let me know if you are still having issues, I am here to help!
thanks Oli, yep I've implemented the app router, will let you know if I face any issues