Next.js · Junior · Question 16 of 75
How do you create a GET /api/users API endpoint in the App Router?
- ✓Correct answer: A file
app/api/users/route.tsexporting aGETfunction - 2A file
app/api/users/page.tsxwith a default export - 3A file
api/users.tsin the project root withexport default handler
Explanation
Route Handlers use the Web Request/Response APIs: export async function GET(request: Request) { return Response.json(users) }. POST, PUT, PATCH, DELETE and others are supported. A folder can't contain both route.ts and page.tsx.