Next.js API
The below code is for use with the app router version of Next.js
Depending on how you set up you installation your pages will be in either “src/app/api” or “app/api”. I will be using “src/app/api” for the Next snippets.
Basic route structure
You create routes using a folder structure and your logic goes into a file called route.ts if you are using Typescript or route.js if you are not using Typescript.
URL: domain.com/api/myroute
File path: src > app > api > my route > route.ts