Next.js Discord

Discord Forum

Auth0 + Next.js 15 issues

Answered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
Hey everyone, I'm trying to use Next.js 15 for the first time with Auth0. Everything is working, the authentication flow, permissions etc, but I keep seeing these logs when I run my app:
Error: Route "/" used `cookies().getAll()`. `cookies()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

That's because i have this line: const session = await getSession()

and also this error:
Error: Route "/api/auth/[auth0]" used `params.auth0`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

this is happening here:
// src/app/api/auth/[auth0]/route.ts
import { handleAuth } from '@auth0/nextjs-auth0';

export const GET = handleAuth();
Answered by B33fb0n3
it looks like the auth0 methods are not yet optimized for next15. So either downgrade to next14 or use a different auth provider (like next-auth for example. But don't next-auth@beta or authjs. They are buggy)

--- Edit
Downgrading is pretty easy as described here: https://nextjs-forum.com/post/1315768887492608060#message-1315793262384251022
View full answer

11 Replies

Answer
@American black bear maybe should I downgrade to next 14? or maybe should I deploy with these errors? bcs it's working, it's just these errors on the console
I wouldn't just deploy it, as this is a very important service (auth in general). So when there are errors inside your auth system you could potentially leak secret data. You don't want that.

I recommend (and current am) downgraded to next14
American black bearOP
yeah, seems like the best thing to do
nextjs provides an easy command to downgrade to a specific version?
@American black bear nextjs provides an easy command to downgrade to a specific version?
yea, switch this number from next15 to (for example) 14.2.5 and use npm install to downgrade. Make sure you downgrade ereact and react-dom to 18 as well. Then scan thought your code (with typescript) to see stuff that comes thought next15 and "downgrade" them. The other "errors" that you got from auth0 will be fixed automatically 👍
American black bearOP
yup, I'm using react 19 rc version
yeah cool, thanks mate
happy to help
Forest bachac
I had this issue and I fixed it by upgrading to auth0 version 4. nextjs-auth0 version 4 doesn't use an API route and instead you set up your auth0 handlers in a library folder