Next.js · Junior · Question 16 of 75

How do you create a GET /api/users API endpoint in the App Router?

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.

Further reading

Problem with a question

Next.js · Junior · question 16

Test yourself

Take the Next.js · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz