#valid route ?

1 messages · Page 1 of 1 (latest)

dark mauveBOT
#

Hi @cosmic wind. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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.

For more information, you can refer to the Next.js documentation on Route Handlers (https://nextjs.org/docs/app/building-your-application/routing/route-handlers) and API Routes (https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#api-routes).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: