From 657dd57ef7702541ff9ca45ee8d46880dbe41376 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Sun, 7 May 2023 14:30:01 +0200 Subject: [PATCH] fix(docs): clean up v5 migration intro --- docs/docs/getting-started/upgrade-to-v5.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/docs/getting-started/upgrade-to-v5.md b/docs/docs/getting-started/upgrade-to-v5.md index 9e10d4ab..e38f0343 100644 --- a/docs/docs/getting-started/upgrade-to-v5.md +++ b/docs/docs/getting-started/upgrade-to-v5.md @@ -2,14 +2,30 @@ title: Upgrade Guide (v5) --- -Auth.js version 5 includes a few breaking changes from the last major version (4.x). So we're here to help you upgrade your applications as smoothly as possible. It should be possible to upgrade from any version of 4.x to the latest 5 release by following the next few migration steps. +NextAuth.js version 5 will continue to be shipped as `next-auth` *for the Next.js version only*. We're here to help you upgrade your applications as smoothly as possible. It is possible to upgrade from any version of 4.x to the latest v5 release by following the migration steps below. -You can upgrade to the new version by running: +Upgrade to the latest version by running: ```bash npm2yarn2pnpm npm install next-auth ``` +## Getting Started + +Below is a summary of the high-level API changes in `next-auth` v5. + +``` +| Where | Old | New | +| ------------------------- | --------------------------------------------------- | -------------- | +| API Route (Node) | getServerSession(req, res, authOptions) | auth() wrapper | +| API Route (Edge) | - | auth() wrapper | +| getServerSideProps | getServerSession(ctx.req, ctx.res, authOptions) | auth() wrapper | +| Middleware | withAuth(middleware, subset of authOptions) wrapper | auth() wrapper | +| Route Handler | - | auth() wrapper | +| Server Component | getServerSession(authOptions) | auth() call | +| Client Component | useSession() hook | useAuth() hook | +``` + ## Summary