Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next 13.4 where is the api Folder?

I have a question regarding Next 13.4. Since today I can only use Next 13.4. I wonder where the api folder has gone. It is no longer created in this version. It still worked in 13.3. How can I now make a POST or GET request and the result with NextResponse return?

like image 945
Captai-N Avatar asked Mar 03 '26 14:03

Captai-N


1 Answers

If there isn't any /api folder, you can make one inside /app folder.

In Next 13.4, the api endpoints are treated as route.js, just like page.js.

e.g /app/api/home/route.js

import { NextResponse } from 'next/server';

export async function GET() {
  return NextResponse.json({ name: 'Anuj Singh' });
}

so from browser if you navigate to /api/home you will see the result.\

More info on this from official doc : https://nextjs.org/docs/app/building-your-application/routing/router-handlers

like image 55
Anuj Singh Avatar answered Mar 06 '26 01:03

Anuj Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!