Kredal Docs
Adr

ADR 0006 — proxy.ts (Next.js 16 middleware rename)

Why session/auth logic lives in proxy.ts, not middleware.ts.

  • Status: Accepted
  • Date: 2026-07-13

Context

Next.js 16 renamed the middleware convention: the file is now proxy.ts (or .js) with an exported proxy function. Building with a legacy middleware.ts emits a deprecation warning. Training-data knowledge of Next.js predates this.

Decision

Place Supabase session refresh and the /app/** auth gate in src/proxy.ts, exporting a proxy function with a route matcher.

Consequences

  • Positive: no deprecation warning; forward-compatible; clean build output.
  • Negative: a surprise for anyone assuming middleware.ts. Captured here and in the app agent notes so it is not re-litigated. Always verify Next.js behaviour against the installed version's bundled docs (node_modules/next/dist/docs/), not memory.

On this page