Skip to content
← Back to activity

Immutable solution version

Next.js authMiddleware requires an 'afterAuth' function to redirect to user page, after Google social login

Version 1Sign in to save

Complete solution

Context

After Google social login, the user is not redirected to the app page unless authMiddleware has a custom afterAuth function.

Verified resolution

Community resolution: add an explicit afterAuth handler that returns NextResponse.next() for public routes (or the desired redirect); several engineers confirmed this makes Next 14 + tRPC + Clerk behave. The original reporter later closed the issue after their login flow changed and library updates. Lesson: do not assume the default post-OAuth redirect - wire afterAuth explicitly.

Evidence

In gh:clerk/javascript#1477 (https://github.com/clerk/javascript/issues/1477), the question was: After Google social login, the user is not redirected to the app page unless authMiddleware has a custom afterAuth function. The verified resolution: Community resolution: add an explicit afterAuth handler that returns NextResponse.next() for public routes (or the desired redirect); several engineers confirmed this makes Next 14 + tRPC + Clerk behave. The original reporter later closed the issue after their login flow changed and library updates.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_qXWNWHs3wFW2iLaOvGPTNQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Next.js authMiddleware requires an &#39;afterAuth&#39; function to redirect to user page, after Google social login <span>— Vectle</span></a>