Upgrade to Next 16, React 19, and AuthKit v4#16
Conversation
Greptile SummaryThis PR upgrades the starter kit to Next.js 16, React 19, AuthKit v4, WorkOS Node SDK v10, and ESLint 9, migrating all implementation to the corresponding new APIs. The changes are thorough and well-executed across all affected surfaces.
Confidence Score: 5/5Safe to merge — all AuthKit v4, Node SDK v10, and Next.js 16 API surfaces are correctly updated with no regressions visible in the changed paths. Every major breaking-change call site was updated consistently: the proxy file, session retrieval, sign-in/sign-up URL generation (correctly moved to Route Handlers), Admin Portal API renames, and the widgets token shape change. The vendored next-themes fork addresses the React 19 inline-script behaviour change with a well-understood useSyncExternalStore pattern. The setup script now uses a public API for secret masking. No hardcoded secrets, no TLS bypasses, and no sensitive field logging were introduced. No files require special attention. Important Files Changed
|
|
|
||
| export async function SignInButton({ large, signUp }: { large?: boolean; signUp?: boolean }) { | ||
| const { user } = await withAuth(); | ||
| const authorizationUrl = signUp ? await getSignUpUrl() : await getSignInUrl(); |
There was a problem hiding this comment.
These functions can write to cookies, which is forbidden in Next 16 server components. This has to be done in server actions.
| return ( | ||
| <Button asChild size={large ? '3' : '2'}> | ||
| <Link href={authorizationUrl}>{signUp ? 'Sign Up' : 'Sign In'}</Link> | ||
| <Link href={signUp ? '/sign-up' : '/sign-in'}>{signUp ? 'Sign Up' : 'Sign In'}</Link> |
There was a problem hiding this comment.
question: any reason this isn't using authorizationUrl anymore?
There was a problem hiding this comment.
const authorizationUrl = signUp ? await getSignUpUrl() : await getSignInUrl();It's because getSignUpUrl and getSignInUrl both set cookies. Next 16 only allows setting cookies via server actions or route handlers. As originally written, this resulted in a runtime error in development (probably a good idea to update the SDK docs here).
Summary
This PR updates all major dependencies to their latest versions and migrates the implementation to the corresponding new APIs.
Dependency updates
15.5.8→^16.2.10(+eslint-config-next16)^18.3.1→^19.2.7(+@types/react/@types/react-dom19)^0.16.1→^4.2.0^7.33.0→^10.7.01.0.0→1.15.0^16.12.0→^22.3.2^5.9.3→^6.2.3(no breaking changes affecting our implementation)^8→^9(flat config)^20→^24(added.nvmrcto run against current LTS)@radix-ui/react-avatar/@radix-ui/react-tooltipwith the consolidated
radix-uipackageImplementation changes
NextJS
npx create next-appsrc/middleware.ts→src/proxy.tsAuthKit v4
authkitMiddleware()→authkitProxy()AuthKitProviderfrom the root layoutgetSignInUrl/getSignUpUrlcalls with dedicated/sign-inand/sign-uproute handlers that redirect to the auth URLs (cookies can only be written in server actions)getSession()→authkit(request)and hardened the session user guardWorkOS Node SDK v10
workos.portal.generateLink→workos.adminPortal.generateLinkGeneratePortalLinkIntent→GenerateLinkIntentworkos.widgets.getToken(...)→workos.widgets.createToken(...)(now returns{ token })React 19 / theming
next-themesintosrc/lib/next-themes.tsx. This was adapted for React 19 to avoid dev errors on startup (server-rendered inline scripts no longer execute, so the theme script no-ops after hydration).Tooling / config
eslint.config.mjsfor ESLint 9;next lint→eslintnext.config.ts,.nvmrc(Node 24),pnpm-workspace.yaml,.prettierignoretsconfig.json:targetes5 → ES2017,jsxpreserve →react-jsx, include.next/dev/typesand**/*.mts.gitignorenow ignores all.env*files except.env.examplescripts/setup.ts:.env.localinstead of overwriting, improves error outputTest plan
pnpm installsucceedspnpm buildpassespnpm lintpassespnpm setupwrites/updates.env.localcorrectly