nextauthjs / nextauthjs/next-auth

Migrating to v5 (NextAuth)

Open
#12,167 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the migrating-to-v5 documentation page and its App Router example, then review the Pages Router paths mentioned in the issue: pages/api/auth/[...nextauth].ts and app/api/auth/[...nextauth]/route.ts. Document a workable Pages Router migration path and clarify or revise the statement about breaking changes; the documentation should address NextApiRequest constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
authentication, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.