Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to v5 (NextAuth) #12167

Open
sKopheK opened this issue Nov 1, 2024 · 2 comments
Open

Migrating to v5 (NextAuth) #12167

sKopheK opened this issue Nov 1, 2024 · 2 comments
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@sKopheK
Copy link

sKopheK commented Nov 1, 2024

What is the improvement or update you wish to see?

The old configuration file, contained in the API Route (pages/api/auth/[...nextauth].ts / app/api/auth/[...nextauth]/route.ts), now becomes much shorter. These exports are designed to be used in an App Router API Route, but the rest of your app can stay in the Pages Router if you are gradually migrating!

app/api/auth/[...nextauth]/route.ts

import { handlers } from "@/auth"
export const { GET, POST } = handlers

Is there any context that might help us understand?

the example above can't be applied to Pages Router which receives NextApiRequest which is basically IncomingMessage from http node module.
i've been trying to migrate from v4 to v5 in larger project still using pages router (migrated from nextjs v12 only recently) for two days by now, but it seems to be really hard (going error by error, searching issues and discussions here, googling around as well and using bits and pieces to make it work), although "we introduced as few breaking changes as possible." I might remove the quoted sentence from the documentation too as it's really misleading

Does the docs page already exist? Please link to it.

https://authjs.dev/getting-started/migrating-to-v5

@sKopheK sKopheK added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Nov 1, 2024
@1saifj
Copy link

1saifj commented Nov 3, 2024

i guess the next-auth documentation should be reviewed

@nic-vo
Copy link

nic-vo commented Nov 18, 2024

Unfortunately the new route handlers are designed around App router API routes. You can keep your existing project in the pages router and just add the necessary handlers under src/app/api/auth/[...nextauth]/route.ts.

Next.js can route to both App router and Pages router routes as long as they don't have the same path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

3 participants