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.
How the converter works
- 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
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
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
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
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
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.ipExplicit 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
| Scenario | What to paste | What to check |
|---|---|---|
| Migrating a simple auth-check middleware | Your full middleware.ts | Zero warnings usually means it's ready to test |
| Auditing a complex middleware file before migrating | The full file including config | Every Edge-pattern warning, one by one |
| Writing a migration PR | Your full file | Use the side-by-side diff as your PR's starting point |
| Learning what proxy.ts looks like | Load example | See a real conversion, including a triggered warning |
| Deciding whether to migrate now or wait | Your full file | If 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?
- Paste — drop your full middleware.ts contents into the input box above
- Convert — click Convert to proxy.ts to run the export rewrite and Edge-pattern scan
- Review warnings — read every flagged line before assuming the conversion is safe to ship
- Copy and rename — copy the converted output, save it as proxy.ts, and delete or keep middleware.ts depending on your migration plan
MiddlewareToProxy vs the official Next.js codemod: which should I use?
| MiddlewareToProxy | npx @next/codemod@canary upgrade latest | |
|---|---|---|
| Setup required | None, paste and go | Requires a real project checkout |
| Scope | One file, previewed instantly | Applies across your whole Next.js 16 upgrade |
| Edge-pattern warnings | Yes, flags known risky lines | No, it only performs the mechanical codemod |
| Best for | Previewing one file or writing a migration PR | Applying 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.
// Flagged pattern
if (request.geo?.country === 'GB') { ... }
// One option: read a platform header directly instead
const country = request.headers.get('x-vercel-ip-country')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.
// 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.