nextjs16-proxy-middleware

Implement Next.js 16 proxy pattern to replace middleware.ts for route protection.

Updated Jan 31, 2026
One-click install
npx skills add https://github.com/JordiNodeJS/.github-config --skill nextjs16-proxy-middleware
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs16-proxy-middleware
Source: https://github.com/JordiNodeJS/.github-config/tree/main/.github/skills/nextjs16-proxy-middleware
Command: npx skills add https://github.com/JordiNodeJS/.github-config --skill nextjs16-proxy-middleware

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a guided approach to implementing the Next.js 16 proxy pattern to replace the legacy middleware.ts for route protection and authentication, simplifying secure routing in serverless environments.

Core Features & Use Cases

  • Migration guidance: from middleware.ts to proxy.ts with minimal changes.
  • Authentication & route protection: protect selected routes and manage login redirects.
  • Matcher configuration examples: practical patterns to target app routes while excluding static assets.
  • Migration-ready patterns: best practices for session handling and safe redirects in Next.js 16.

Quick Start

Add a proxy.ts with a proxy() export and a config.matcher to your Next.js project, then test protected routes by starting the dev server and hitting a guarded URL.

Frequently Asked Questions about nextjs16-proxy-middleware

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate from middleware.ts to the Next.js 16 proxy pattern for route protection?

To migrate from middleware.ts to the Next.js 16 proxy pattern, add a proxy.ts file with an exported proxy function and a config.matcher. This migration requires minimal changes to replace the legacy middleware for route protection and authentication in serverless environments.

What is the Next.js 16 proxy pattern used for?

The Next.js 16 proxy pattern is used to protect routes and manage authentication by replacing the legacy middleware.ts. It simplifies secure routing in serverless environments by using an exported proxy function and a config.matcher pattern in a proxy.ts file.

How do I configure a matcher in proxy.ts to exclude static assets?

You configure a matcher in proxy.ts by defining a config.matcher pattern that specifically targets your protected app routes. This configuration ensures the proxy function processes dynamic authentication checks while safely excluding static assets from route protection logic.

Do I need TypeScript to use the Next.js 16 proxy pattern for authentication?

Yes, implementing the Next.js 16 proxy pattern for authentication requires TypeScript and Next.js 16 in a Node.js project. This setup ensures proper session handling, protected routes, and safe redirects within your serverless environment.

What's the best way to handle login redirects with Next.js 16 proxy.ts?

The best way to handle login redirects with Next.js 16 proxy.ts is by applying migration-ready patterns for session handling and safe redirects. This approach maintains secure routing and authentication logic when replacing the legacy middleware.ts.