iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Next.js 16 deprecates the middleware file convention and replaces it with proxy. Move middleware.ts (or .js) to proxy.ts, rename a named middleware export to proxy, and update configuration keys such as skipMiddlewareUrlNormalize to skipProxyUrlNormalize. The official migration codemod is npx @next/codemod@canary middleware-to-proxy .
The rename also clarifies the feature’s role: Proxy is a network boundary that runs before a route is rendered. A compact matcher such as /((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*) uses one negative-lookahead expression to decide which paths receive redirects, rewrites, header changes, cookies, or early responses. That expression is a policy, not a performance benchmark or an authentication system.
Why did Next.js rename Middleware to Proxy?
Next.js says the middleware name can be confused with Express.js middleware and can encourage using the feature for work better handled elsewhere. “Proxy” describes what the code actually does: it sits at a request boundary and can alter traffic before the application renders a route. The rename appeared in the Next.js 16.0.0 documentation version history, where the old convention is marked deprecated.
This is more than a cosmetic rename. The framework recommends avoiding Proxy unless no simpler option fits. Route handlers, layouts, Server Functions, and ordinary application code are usually better places for logic that belongs to a specific route or operation. Proxy is appropriate when one request-level rule must apply before routing completes, such as a programmatic redirect, an A/B rewrite, request logging, or a header policy.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
A third-party article’s “22-line proxy” example illustrates how little code a request boundary can require, but 22 lines is not an official Next.js implementation size, latency result, or performance target. Next.js does not promise that a particular Proxy will have that size or speed.
How do I migrate middleware.ts to proxy.ts in Next.js 16?
For a typical project, the migration is mechanical. Complete every step, then test which routes are matched; a file that builds successfully can still have the wrong coverage.
- Rename the file. Change
middleware.tsormiddleware.jstoproxy.tsorproxy.js. Put it at the project root, or undersrcbeside theapporpagesdirectory. - Rename the named export. Change
export function middleware(request) { ... }toexport function proxy(request) { ... }. A default export remains supported, so a default-exported function does not need a name change for the export itself. - Run the codemod if you want automated edits. From the project directory, run
npx @next/codemod@canary middleware-to-proxy .Review its changes rather than assuming every custom configuration or comment has been interpreted correctly.
- Rename configuration flags. Replace names containing
middlewarewhere Next.js has supplied a Proxy equivalent. For example,skipMiddlewareUrlNormalizebecomesskipProxyUrlNormalize. - Check runtime assumptions. In Next.js 16, Proxy runs on the Node.js runtime by default, and the
runtimeoption cannot be configured in a Proxy file. Code that depended on Edge-only behavior or APIs needs a deliberate review. - Re-check matchers after route changes. Adding a route, API endpoint, or Server Function can change what must be intercepted. A matcher that once covered every relevant request may silently leave a new path outside Proxy.
Keep the migration in a separate commit when possible. That makes it easier to distinguish a naming change from a behavior change if a redirect, cookie, or authorization flow fails.
What does the migrated file look like?
A minimal TypeScript Proxy can export a function and a constant matcher:
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function proxy(request: NextRequest) {
return NextResponse.next()
}
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],
}
The function above allows a request to continue. Replace that response with a redirect, rewrite, header mutation, cookie operation, or another response only when the request policy requires it.
What does the negative-lookahead matcher regex exclude?
The expression is a broad “match everything except these prefixes” rule. In /((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*), the outer slash starts the path pattern at the root. The group beginning with (?! is a negative lookahead: it succeeds only when the path does not begin with any listed alternative. The trailing .* then consumes the rest of the path.
With that exact example, Proxy does not run for paths beginning with api, _next/static, or _next/image, nor for the named favicon.ico, sitemap.xml, and robots.txt files. Everything else that satisfies the matcher can receive the Proxy function’s behavior.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Read each alternative as a business rule. Excluding api means an API request will not receive a redirect or header added by this Proxy. If an API endpoint needs that behavior, the exclusion is incorrect for your application. Conversely, allowing every static asset through Proxy may add needless request processing and make debugging harder.
Why is the pattern anchored at the start?
Next.js matcher patterns are anchored to the beginning of the path. A prefix such as api therefore tests the beginning of the request path rather than an arbitrary substring later in the URL. Matcher values must be constants so Next.js can analyze them at build time; constructing a matcher dynamically prevents the framework from reliably determining coverage.
What about _next/data requests?
Next.js documents special handling for _next/data requests. This protects against a situation where a page appears protected by Proxy while its data route is left exposed. Treat data requests as part of the same access-control design as the page itself, and verify both forms during testing instead of relying only on a browser navigation.
Should I use a negative-lookahead matcher or explicit paths?
Neither form is universally better. A negative lookahead is compact for a site-wide policy with a short, stable exclusion list; explicit matcher entries are easier to audit when only a few areas need protection.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →| Decision point | Negative-lookahead rule | Explicit path entries |
|---|---|---|
| Readability | One concise expression, but readers must parse regular-expression syntax. | Each protected path is visible as a separate entry. |
| Accidental exclusions | A newly added prefix can unintentionally bypass Proxy across an entire branch. | Coverage is narrower and omissions are easier to spot in review. |
| API and Server Function coverage | Broad by default, unless an exclusion such as api removes it. |
Only listed paths are covered, so every required endpoint must be named. |
| Static-asset overhead | Can avoid common _next assets and metadata with one rule. |
Can avoid overhead by listing only application paths, but the list may grow. |
| Testing after route changes | Requires focused tests for excluded prefixes and newly introduced routes. | Reviewing the array is straightforward, although missing a path remains possible. |
Whichever style you choose, add a comment explaining the policy and test representative URLs. A compact expression is not safer merely because it is shorter.
What can Next.js Proxy do before a route runs?
Proxy executes before route rendering and can make a decision at the request boundary. Its supported uses include:
- Redirecting a request to another URL based on the path, host, cookie, or other request information.
- Rewriting a request internally so the browser keeps its URL while another route handles the response.
- Adding, removing, or changing request and response headers.
- Setting cookies or returning a response directly without rendering the destination route.
- Logging requests and applying lightweight, optimistic permission redirects.
- Choosing between variants for an experiment or A/B route split.
These operations should remain fast and request-focused. Proxy is not intended for slow data fetching. Fetching a database record or performing a long-running computation at this boundary increases the work done for every matched request and can make static files or navigation unexpectedly dependent on that operation.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Can Proxy replace authentication and authorization?
No. Proxy can provide an early redirect for an unauthenticated visitor, but it is not a complete session-management or authoritative authorization layer. The getting-started guidance specifically warns against treating it as one.
Enforce permissions again at the route or Server Function that owns the protected operation. A matcher can omit a path, a new endpoint can be added later, or a request can reach the operation through a route you did not anticipate. The Server Function must verify the session, user identity, and resource permissions before reading or changing protected data.
Use Proxy for the user-experience part of the flow—such as sending a visitor to a sign-in page—while keeping the security decision next to the data or mutation it protects. Never assume that a redirect proves the underlying operation is inaccessible.
Does Next.js 16 Proxy run on Edge or Node?
Next.js 16 Proxy defaults to Node.js. The runtime option is not configurable inside a Proxy file, so a migration from code designed around an Edge runtime requires an API and dependency review.
Next.js 15.5.0 had already made the Node.js runtime a stable option for Middleware. Version 16 makes Node.js the default under the new Proxy convention. Check packages that depend on Edge-specific globals, deployment restrictions, or a particular runtime before upgrading production traffic.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWhy is my Proxy running on static assets?
Usually the matcher does not exclude the asset paths you are requesting, or the pattern is not the constant Next.js can analyze. Start by logging the request pathname in a development build and compare it with the matcher alternatives. Check _next/static, _next/image, metadata files, and any custom asset directory separately.
- If the request starts with a prefix that should bypass Proxy, add that prefix to the exclusion expression or explicit matcher policy.
- If the request is an application route that merely serves a file, decide whether it really should bypass redirects or headers; do not exclude it automatically.
- If a matcher is built from variables or a function call, replace it with a literal constant so build-time analysis can see it.
- After changing the matcher, restart the development server and test a production build, because route analysis occurs during the build.
Do not exclude all API paths just to reduce logging or processing unless every API endpoint truly should bypass the policy. An exclusion also removes legitimate redirects, headers, or optimistic checks.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
How should I test the migration and matcher coverage?
Test behavior, not just compilation. A successful build confirms that the convention is recognized; it does not prove that every protected route is covered.
- Request a normal page that should pass through Proxy and verify its redirect, rewrite, headers, or cookies.
- Request each excluded prefix, including an API route, a static asset, an optimized image, and each metadata file named in the matcher.
- Test nested paths such as
/dashboard/settingsand paths that merely contain an excluded word later in the URL. - Exercise both a browser navigation and the corresponding data request for pages that use Next.js data loading, including an
_next/datarequest where applicable. - Call every protected Server Function directly with an invalid or missing session and confirm that the function itself denies the operation.
- Repeat the checks after adding a route or changing a Server Function, because route evolution can create silent coverage gaps.
Keep a small table of expected outcomes—continue, redirect, rewrite, or deny—for representative paths. This makes a regular-expression change reviewable and catches accidental policy changes before deployment.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
What are the common migration mistakes?
Leaving the old filename in place
Keeping middleware.ts while adding proxy.ts can create confusion about which convention is active and may leave deprecated behavior in the project. Rename or remove the old file rather than maintaining two competing entry points.
Renaming the file but not the export
A named middleware export should become proxy. A default export remains valid, but mixed naming in helper files and tests can make the migration appear complete when the entry point is not the one you intended.
Updating the function but not configuration
Flags that still contain the old convention’s name can be ignored or fail validation after the migration. Search configuration files, build scripts, and environment-specific settings for middleware, then apply the documented Proxy spelling where one exists.
Assuming the regex is an authorization rule
A matcher determines whether Proxy runs; it does not prove that a user may access a resource. Put the final permission check in the route or Server Function that performs the sensitive operation.
Recommended Free Tools
Copying an exclusion list without checking the application
The example excludes api, but an application may need Proxy to add security headers, select a tenant, or redirect an API request. Treat every prefix as an intentional policy decision and document why it is included.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
When should I avoid Proxy altogether?
Avoid it when a simpler, more local mechanism can solve the problem. A route-level redirect belongs with the route; a data permission check belongs in the Server Function or data-access layer; and a slow database lookup should not run for every request at the network boundary.
Use Proxy when the decision genuinely spans routes or must happen before rendering—for example, a host-based rewrite, a lightweight locale redirect, a request-wide header, or an optimistic sign-in redirect. Keep the function small, keep matchers auditable, and move authoritative business rules closer to the operation they protect.
Frequently Asked Questions
Will Next.js 16 remove support for my existing middleware immediately?
The convention is deprecated and renamed, so existing projects may continue to build during a transition, but the supported direction is to migrate to Proxy. Treat deprecation warnings as upgrade work rather than waiting for a later release to force the rename.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Can a Proxy function use a default export after migration?
Yes. Next.js continues to support a default export in the Proxy file. The required naming change applies to a named export; still keep one clear entry-point style so code review and tests identify the active function.
How can I tell whether a matcher pattern is being analyzed by Next.js?
Keep the config.matcher value as a literal constant array or string and inspect the build output and runtime logs for representative paths. A matcher assembled from variables is not reliably available to build-time route analysis, even if the resulting string looks correct at runtime.
Does the rename change the regular-expression syntax?
No. The matcher still uses Next.js path patterns and regular expressions, including negative lookaheads. The migration changes the file convention, export name, and related configuration keys; it does not automatically rewrite your path policy.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

