Upgrade example app to Next.js 16, React 19, and AuthKit v4 - #75
Draft
Rmole57 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades the example app from Next.js 14.1.4 to 16.2.12, which pulls React 19 and
majors of both WorkOS SDKs along with it. All required migrations are applied here.
Dependencies
nextreact/react-dom@workos-inc/authkit-nextjs@workos-inc/nodeeslinteslint-config-next@types/react/@types/react-domBreaking changes handled
Next.js 16
src/middleware.ts→src/proxy.ts,authkitMiddleware→authkitProxy. Next 16 errors (E900) if both files exist.searchParamsis nowPromise<…>in 7 pages, andcookies()is awaited inwith-session/auth.ts.reset-password/page.tsxis a Client Component, so it unwraps viause(searchParams).next lintwas removed:.eslintrc.json→eslint.config.mjs(flat config),lintscript is now plaineslint.tsconfig:targetes5→ES2017; Next's build also requiresjsx: react-jsxand adds.next/dev/types.React 19
useFormState(react-dom) →useActionState(react) across 8 components.authkit-nextjs v4
getUser()→withAuth(); added the now-requiredAuthKitProviderto the root layout.WORKOS_REDIRECT_URI→NEXT_PUBLIC_WORKOS_REDIRECT_URIin.env.local.exampleand inusing-hosted-authkit/README.md. v4 reads only the prefixed name.getSignInUrl()writes a PKCE cookie, so Next 16 forbids calling it during render. Thewith-nextjsexample now signs in via a POST Server Action instead of an<a href>.@workos-inc/node v10
workos.mfa→workos.multiFactorAuth;userManagement.enrollAuthFactor→multiFactorAuth.createUserAuthFactor;sendMagicAuthCode→createMagicAuth.Behavior change worth a look
sendPasswordResetEmailis gone. Its replacement,createPasswordReset, dropped thepasswordResetUrlinput and no longer sends an email — it mints the token and returns it, so delivery is now the application's responsibility. The example renders a labelled link to keep the flow clickable, and comments on why a real app must email the token instead. This is the one place where the example demonstrates something different than before, so it may warrant a product call rather than just a mechanical migration.Also in this PR
yarn.lockremoved,package-lock.jsonadded, README install step updated. The committedyarn.lockwas in Yarn Berry format while Yarn 1 is what most environments resolve, so installs had been rewriting it inconsistently.JWT_SECRET_KEYto.env.local.example— thewith-sessionexample already required it but it was undocumented.Upgrading an existing local checkout
Only one step isn't covered by this PR, because the file is gitignored: rename
WORKOS_REDIRECT_URItoNEXT_PUBLIC_WORKOS_REDIRECT_URIin your own.env.local(the value is unchanged). The old name is silently ignored, so auth fails with no clear error.Testing
tsc --noEmitcleaneslintcleannext buildgreen — 29/29 routes,proxy.tsdetected