Dev Encyclopedia
ArticlesToolsContactAbout

Get notified when new content drops

No spam. Just new articles, tools, and updates straight to your inbox.

Dev Encyclopedia

A reference for builders

Content

  • Articles
  • Tools
  • About
  • Contact

Connect

  • support@devencyclopedia.com
  • RSS Feed

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

© 2026 Dev Encyclopedia

Back to top ↑
  1. Home
  2. /
  3. Tools
  4. /
  5. MiddlewareToProxy
Free · Live

Convert middleware.ts to proxy.ts in one paste

Paste your Next.js middleware.ts file and get the proxy.ts equivalent instantly, with warnings for any Edge-runtime-specific patterns worth testing before you deploy.

Zeeshan Tofiq

Zeeshan Tofiq

Full Stack Developer

How the converter works

  1. 1

    Paste your middleware.ts file

    Drop in your full file, including imports, the exported function, and the config block if you have one. The converter works on real files, not fragments.

  2. 2

    Export pattern detection

    The tool scans for the exported middleware function: a named export function middleware(), a default export function middleware(), or an arrow function assigned to export const middleware.

  3. 3

    Export rewrite

    The matched export is converted to the proxy.ts shape: export default function proxy(). Arrow-function exports get renamed and a default export line appended, since an arrow const can't be exported default in place.

  4. 4

    Edge-pattern scan

    Every line is checked against a small known list of Edge-runtime-specific patterns: request.geo, request.ip, explicit runtime: 'edge' config, streamed responses, and WASM imports.

  5. 5

    Side-by-side diff and change list

    The original file and the converted output are shown next to each other, with a plain-language list of exactly what changed and why underneath.

  6. 6

    Copy, save, and test

    Copy the converted output, save it as proxy.ts, and run next dev to exercise every path your matcher covers before deploying to production.

What the output means

The converter produces a rewritten file, a change list, and Edge-pattern warnings. Here is what each category means and what triggers it.

Export conversion

Always applied. Rewrites the middleware export to the proxy.ts shape Next.js 16 expects.

// Before: export function middleware(request: NextRequest) {
// After:  export default function proxy(request: NextRequest) {

request.geo warning

Triggered by request.geo or req.geo anywhere in the file. Edge runtime populated this automatically; confirm the equivalent exists under Node.js.

// Triggers on:
if (request.geo?.country === 'GB') { ... }

request.ip warning

Triggered by request.ip or req.ip. Read the client IP from a platform header (e.g. x-forwarded-for) under the Node.js runtime instead.

// Triggers on:
const ip = request.ip

Explicit edge runtime warning

Triggered by runtime: 'edge' or runtime: 'experimental-edge' in a config export. This is a deliberate Edge opt-in worth a conscious decision.

// Triggers on:
export const config = { runtime: 'edge' }

Streaming response warning

Triggered by ReadableStream anywhere in the file. Streamed responses can behave differently under the Node.js runtime.

// Triggers on:
return new Response(new ReadableStream({ ... }))

WASM import warning

Triggered by a .wasm import path. These were often used to work around Edge runtime restrictions and may no longer be necessary.

// Triggers on:
import wasm from './geo.wasm'

Supported middleware.ts export syntax

The converter recognizes these export shapes. If your file uses something else, it returns an error instead of guessing.

Named function export

export function middleware(request: NextRequest) {
  // ...
}

Async named function export

export async function middleware(request: NextRequest) {
  // ...
}

Default function export

export default function middleware(request: NextRequest) {
  // ...
}

Arrow function assigned to a const

export const middleware = (request: NextRequest) => {
  // ...
}

config export (left unchanged)

export const config = {
  matcher: ['/dashboard/:path*'],
}

When to use this tool

ScenarioWhat to pasteWhat to check
Migrating a simple auth-check middlewareYour full middleware.tsZero warnings usually means it's ready to test
Auditing a complex middleware file before migratingThe full file including configEvery Edge-pattern warning, one by one
Writing a migration PRYour full fileUse the side-by-side diff as your PR's starting point
Learning what proxy.ts looks likeLoad exampleSee a real conversion, including a triggered warning
Deciding whether to migrate now or waitYour full fileIf warnings appear, benchmark under proxy.ts before switching

Frequently Asked Questions

What does MiddlewareToProxy do?

It takes a Next.js middleware.ts file and rewrites it into the proxy.ts equivalent Next.js 16 expects: the named middleware export becomes a default export named proxy. It also scans your file for a small list of known Edge-runtime-specific patterns and flags each one so you know exactly what to test before deploying.

  • Export conversion — rewrites the function export to the proxy.ts shape
  • Side-by-side diff — shows your original file next to the converted output
  • Edge-pattern warnings — flags lines using request.geo, request.ip, explicit edge runtime config, streaming responses, or WASM imports
How do I convert middleware.ts to proxy.ts?
  1. Paste — drop your full middleware.ts contents into the input box above
  2. Convert — click Convert to proxy.ts to run the export rewrite and Edge-pattern scan
  3. Review warnings — read every flagged line before assuming the conversion is safe to ship
  4. Copy and rename — copy the converted output, save it as proxy.ts, and delete or keep middleware.ts depending on your migration plan

💡 Tip

For simple auth-check or redirect middleware with zero warnings, the conversion is usually ready to test as-is. For anything flagged, test under the Node.js runtime before deploying.

MiddlewareToProxy vs the official Next.js codemod: which should I use?
MiddlewareToProxynpx @next/codemod@canary upgrade latest
Setup requiredNone, paste and goRequires a real project checkout
ScopeOne file, previewed instantlyApplies across your whole Next.js 16 upgrade
Edge-pattern warningsYes, flags known risky linesNo, it only performs the mechanical codemod
Best forPreviewing one file or writing a migration PRApplying the full upgrade to a real project

Use MiddlewareToProxy to preview the change or sanity-check a complex file before you touch your project. Use the official codemod when you're ready to apply the full Next.js 16 upgrade across your codebase, they solve different parts of the same migration.

Is my middleware.ts code sent to a server?

No. The entire conversion runs in your browser using pattern-based string matching. Nothing is uploaded, stored, or transmitted anywhere. You can confirm this by opening your browser's network tab while using the tool.

How do I fix an 'Edge-runtime pattern to review' warning?

Each warning names the specific line and pattern, then explains what to check. For request.geo, for example, confirm your deployment target still populates that property under the Node.js runtime, or switch to reading a platform-specific header instead.

typescript
// Flagged pattern
if (request.geo?.country === 'GB') { ... }

// One option: read a platform header directly instead
const country = request.headers.get('x-vercel-ip-country')

⚠ Warning

A warning doesn't mean the conversion is wrong, it means that specific line depends on Edge-runtime behavior that may differ under Node.js. Test it before deploying.

Does this tool support arrow-function middleware exports?

Yes. If your file uses export const middleware = (request: NextRequest) => { ... } instead of a function declaration, the tool renames the constant to proxy and appends a export default proxy; line, since an arrow function assigned to a const can't be exported as default in place.

typescript
// Before
export const middleware = (request: NextRequest) => { ... }

// After
const proxy = (request: NextRequest) => { ... }

export default proxy;
What is proxy.ts in Next.js 16?

proxy.ts is the Next.js 16 replacement for middleware.ts. It lives at the project root, exports a default function named proxy, and runs on the Node.js runtime by default instead of the Edge runtime middleware.ts used. middleware.ts still works during a deprecation window, it's just no longer the default path for new code.

Related reading

Guide

Next.js middleware.ts to proxy.ts: What Changes

The full migration guide: why the runtime default changes, a step-by-step walkthrough, and what breaks if you used Edge-only APIs.

Guide

How to Use Environment Variables in Next.js

How NEXT_PUBLIC_ works, build-time vs runtime resolution, and type-safe validation, relevant since middleware is one of the few places both come into play.

Zeeshan Tofiq

Zeeshan Tofiq

Full Stack Developer

Full stack developer with over 6 years of experience building production applications. Writes practical guides on JavaScript, TypeScript, React, Node.js, and cloud infrastructure. Focused on helping developers solve real problems with clean, maintainable code.

Enjoyed this article?

Get practical dev guides, tool updates, and new articles delivered straight to your inbox. No spam, unsubscribe anytime.