Skip to content

Serve the SSR auth routes from one handler - #782

Closed
erquhart wants to merge 2 commits into
rebootfrom
ssr-single-handler
Closed

erquhart wants to merge 2 commits into
rebootfrom
ssr-single-handler

Conversation

@erquhart

Copy link
Copy Markdown
Member

Problem

setupConvexAuthServer returns three handlers, so a Next app mounts three route files under app/auth/, each a one-line re-export of one handler.

Change

setupConvexAuthServer also returns handler, which dispatches on the last path segment (signin, refresh, signout) and answers 404 to anything else. One file serves all three:

// app/auth/[route]/route.ts
import { auth } from "@/src/lib/serverAuth";
export const POST = auth.handler;

The three individual handlers stay, for frameworks without dynamic segments or apps that want the routes apart. Dispatch is on the last segment only, so the base can be mounted anywhere (/api/account/auth/[route] works the same).

Also

  • Tests: ssr/setup.test.ts covers each route, a nested base path with trailing slash, and the 404.
  • examples/nextjs moves to app/auth/[route]/route.ts; ssr-nextjs/setup.mdx and the example README follow, with the per-file layout kept as a callout.
  • Independent of Export ConvexAuthNextjsProvider so apps own the Convex client under SSR #780 (different files; the docs page is shared but the sections don't overlap).

Validated with pnpm build, check:declarations, lint, typecheck, and the core test suite (902 passing).


Generated by Claude Code

`setupConvexAuthServer` returned three handlers, so a Next app mounted
three route files under `app/auth/`, each a one-line re-export. It now also
returns `handler`, which dispatches on the last path segment (`signin`,
`refresh`, `signout`) and answers 404 to anything else, so one
`app/auth/[route]/route.ts` serves all three. The individual handlers stay
for frameworks without dynamic segments or apps that want them apart.

The example and the Next.js setup docs move to the single route.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RuiNWRbC1cfyoU7jnDzisM
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
auth-v2 Ready Ready Preview Oct 23, 2026 3:40am UTC
1 Skipped Deployment
Project Deployment Actions Updated
convex-auth-docs Ignored Ignored Oct 23, 2026 3:40am UTC

Request Review

…oxy's 400

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RuiNWRbC1cfyoU7jnDzisM
@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@convex-dev/auth@782

commit: 032641f

This branch was successfully deployed

1 active deployment
Preview – auth-v2 — 032641fb Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants