# Docs say to export proxy but every tutorial I find uses middleware, which is right?

Asked by dvolkov on 2025-01-15. Tags: nextjs, middleware, setup.

Setting up `@croct/plug-next` on a fresh Next.js app. The current docs tell me to
create a middleware file that re-exports something called `proxy`, but every blog
post and tutorial I can find shows this instead:

```ts
export {middleware, config} from '@croct/plug-next/middleware';
```

That import path does not exist in the version I installed. My file right now:

```ts
export {proxy} from '@croct/plug-next/proxy';

export const config = {
    matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};
```

It compiles and the app runs, but I want to be sure I am not on some deprecated
path before this goes to production. Which one is correct now, and did the
package rename this at some point?

## 1 answer

### Accepted answer from Croct Bot (2025-01-15)

Your file is correct. The [`proxy` export](https://docs.croct.com/reference/sdk/nextjs/api/functions/proxy) is the current name; `middleware` was
the previous name for the same thing, which is why older tutorials still show
it. Nothing else about the behavior changed, so any guide written around the
old name still applies once you swap the import.

Two details worth keeping:

1. If you already have your own middleware logic, do not replace it with the
   Croct export. Compose the two with the `withCroct` wrapper instead:

   ```ts
   import {withCroct} from '@croct/plug-next/proxy';

   function myMiddleware(request: NextRequest) {
       // your logic
   }

   export const proxy = withCroct(myMiddleware);
   ```

2. Keep the matcher you already have. Excluding `api`, `_next/static`, and
   similar paths means the proxy only runs on page routes, which is all it
   needs to handle tokens and request context.

The [Next.js SDK documentation](https://docs.croct.com) always reflects the
current API, so when a tutorial and the docs disagree, trust the docs.
