Skip to content

SDK: Rename middleware to proxy for Next.js 16 compatibility #12

@sidxz

Description

@sidxz

Context

Next.js 16 renamed the middleware.ts file convention to proxy.ts. The old name still works but logs a deprecation warning on every build/dev start:

⚠ The "middleware" file convention is deprecated. Please use "proxy" instead.

Reference: https://nextjs.org/docs/messages/middleware-to-proxy

Why Next.js renamed it

"Middleware" was confused with Express middleware. "Proxy" clarifies it's a network-level interceptor running at the edge, in front of the app. Next.js is discouraging overuse and plans to provide better alternatives for common use cases.

The migration is a simple rename — the NextRequest/NextResponse API is unchanged:

- // middleware.ts
- export function middleware(req: NextRequest) { ... }
+ // proxy.ts
+ export function proxy(req: NextRequest) { ... }

Codemod available: npx @next/codemod@canary middleware-to-proxy .

What needs to change in @sentinel-auth/nextjs

@sentinel-auth/nextjs/authz-middleware exports createSentinelAuthzMiddleware() which returns a function for the middleware convention.

Suggested changes:

  1. Add @sentinel-auth/nextjs/authz-proxy export path (or rename existing)
  2. Return function should be compatible with the proxy convention name
  3. Update docs/examples to show proxy.ts usage
  4. Optionally keep the old export as a deprecated alias for backwards compat

Severity

Low — deprecation warning only. Apps work fine with middleware.ts today. But the old convention will likely be removed in Next.js 17+.

Discovered in

Chem-Vault2 frontend (S06) using @sentinel-auth/nextjs@0.10.2 + Next.js 16.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions