#valid route ?
1 messages · Page 1 of 1 (latest)
Both app/api/projects/[id]/route.ts and app/projects/[id]/route.ts can be valid routes in Next.js, depending on the context of your application.
In Next.js, API Routes continue to work in the pages/api directory without any changes. However, they have been replaced by Route Handlers in the app directory. Route Handlers allow you to create custom request handlers for a given route using the Web Request and Response APIs. So, if you're defining an API route, you might use app/api/projects/[id]/route.ts.
On the other hand, if you're defining a page route, you might use app/projects/[id]/route.ts.
Here's an example of how you might define a GET method in a Route Handler:
export async function GET(request: Request) {}
Remember, if you previously used API routes to call an external API from the client, you can now use Server Components instead to securely fetch data.