---
title: "Comment by Sreekesh Iyer on \"I'm Jason Lengstorf. I host a live pair programming show called Learn With Jason, I'm the VP of Developer Experience at Netlify. AMA!\" | Hashnode"
description: "I had two questions: How does Netlify handle the Next.js API routes which are converted to serverless functions? Is it possible for us to change the location of"
url: "https://hashnode.com/posts/ama/61dfc8dc8a0e7c6db7fba623/comment/61e02863054d3c75159acfa2"
---

[Discussion](https://hashnode.com/posts/ama/61dfc8dc8a0e7c6db7fba623)

Comment [I'm Jason Lengstorf. I host a live pair programming show called Learn With Jason, I'm the VP of Developer Experience at Netlify. AMA!](https://hashnode.com/posts/ama/61dfc8dc8a0e7c6db7fba623)

[Sreekesh Iyer](https://hashnode.com/@sreekeshiyer)

[Jan 13, 2022](https://hashnode.com/posts/ama/61dfc8dc8a0e7c6db7fba623/comment/61e02863054d3c75159acfa2)

I had two questions:

-   How does Netlify handle the Next.js API routes which are converted to serverless functions? Is it possible for us to change the location of these serverless functions?
-   How does Netlify handle Next.js middleware? (functions written in \_middleware files)

Thanks for the AMA :)

[Jason Lengstorf](https://hashnode.com/@jlengstorf)

[Jan 14, 2022](https://hashnode.com/posts/ama/61dfc8dc8a0e7c6db7fba623/comment/61e02863054d3c75159acfa2#reply-61e1ac641f35f37864468108)

hello!

Netlify handles Next.js API routes the same as other routes, so they don't generate different serverless functions. if you want to customize your serverless functions, you can put them in `netlify/functions/whatever-you-want.js`

to mimic the `/api/*` pattern, you can add this to your `netlify.toml`:

```
[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/:splat"
  status = 200
```

that would let you call `[example.com/api/whatever-you-want](https://example.com/api/whatever-you-want)` to reach your serverless function

for Middleware, we currently handle those requests at our origin. Matt Kane (who knows far more about this than I do) wrote up details here: [github.com/netlify/netlify-plugin-nextjs/blob/mai…](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/middleware.md)

thanks!

[Sreekesh Iyer](https://hashnode.com/@sreekeshiyer)

[Jan 14, 2022](https://hashnode.com/posts/ama/61dfc8dc8a0e7c6db7fba623/comment/61e02863054d3c75159acfa2#reply-61e1b456d546507ab034323e)

[Jason Lengstorf](https://hashnode.com/@jlengstorf)

Thank you!
