Welcome to the Kinde community

Updated 3 days ago

I'm Confused About Next.js Pages Router Documentation

Hi! I've been reading the Next.js Pages Router documentation, and am confused about a few things:

  1. the docs mention app/layout.tsx; that looks like an App Router thing, not a Pagers Router?
  2. The layout imports and wraps an Auth component, but I don't see what that is (or the code for it)?

Attachment
image.png
P
M
3 comments

Hi Martin,

Thank you for reaching out with your questions regarding the Next.js Pages Router SDK documentation.

You're correct in noting that the app/layout.tsx file is associated with the App Router in Next.js, not the Pages Router. The Pages Router SDK utilizes the pages/_app.js file for global configurations. This discrepancy arises because the Pages Router SDK was developed prior to the introduction of the App Router in Next.js. For optimal integration with Next.js 13 and later versions, we recommend using our dedicated Next.js App Router SDK, which is specifically designed for these versions and offers enhanced compatibility. https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/

Regarding the Auth component mentioned in the documentation, it serves as a wrapper to manage authentication state across your application. In the Pages Router SDK, this component is typically imported and used within the pages/_app.js file to ensure that authentication context is available throughout your app. If you're using the App Router, the equivalent setup would involve wrapping your application with the KindeProvider in the app/layout.tsx file. This approach ensures that authentication context is properly managed in your application. https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk

If you have further questions or need additional assistance, please don't hesitate to ask. I'm here to help.

For optimal integration with Next.js 13 and later versions, we recommend using our dedicated Next.js App Router SDK,
I'm using nextjs 15.1 with pages router

Regarding the Auth component mentioned in the documentation, it serves as a wrapper to manage authentication state across your application
Is the component documented somewhere, or code available?

Hi Martin

Is this what you mean? https://docs.kinde.com/developer-tools/sdks/backend/nextjs-prev-sdk/#kinde-auth-data
Also, are you having a specific issue connecting, or is this mostly docs feedback?

Add a reply
Sign up and join the conversation on Slack