Create the Kinde auth endpoint
Next.js App Router setup
Kinde · Function
handleAuth() creates the Next.js route handler for Kinde authentication endpoints. In the App Router, export it as the route’s GET handler from app/api/auth/[kindeAuth]/route.ts.
handleAuth() creates the route handler used by Next.js to expose Kinde authentication endpoints. In the App Router, call it when exporting the route’s GET handler from app/api/auth/[kindeAuth]/route.ts.
handleAuth()A Next.js route handler for Kinde authentication endpoints.
handleAuth from the Kinde Next.js SDK’s server module.app/api/auth/[kindeAuth]/route.ts.GET method.import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";
export const GET = handleAuth();Exports a GET route handler that serves Kinde authentication endpoints in a Next.js App Router application.
Next.js App Router setup
Authentication route exposure
Server-side SDK integration
handleAuth do in the Next.js SDK?handleAuth is imported from @kinde-oss/kinde-auth-nextjs/server and called to produce the handler for Kinde authentication routes. In the App Router, that handler is exported as GET.
Follow-up: How would you expose the endpoint? Create app/api/auth/[kindeAuth]/route.ts and export GET = handleAuth() from it.
handleAuth be placed in an App Router project?The route uses a dynamic [kindeAuth] segment under app/api/auth. This gives the SDK a route location through which Kinde authentication endpoints are handled.
Follow-up: What should the route file contain? Import handleAuth from the server package and export its result as the route’s GET handler.
The current App Router example uses the server entry point, @kinde-oss/kinde-auth-nextjs/server, rather than a client-side import. The resulting function is assigned to the route’s GET export.
Follow-up: How does this differ from the Pages Router? There, the documentation shows a catch-all API file exporting default handleAuth() instead.
withAuthgetKindeServerSessionuseKindeAuth