Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Next.js
Next.jseasy

Route Handlers in the App Router: how do you define them and what are they used for?

Tags
#nextjs#route-handlers#api#app-router
Back to categoryPractice quiz

Answer

You create a `route.ts`/`route.js` file and export HTTP methods like `GET`, `POST`. Handlers use the Web `Request`/`Response` APIs. They’re used for custom APIs, webhooks, or backend logic without a separate server.

export async function GET() {
  return Response.json({ ok: true })
}

Related questions

Next.js
App Router data fetching: what do `cache: 'no-store'` and `revalidate` change?
#nextjs#fetch#cache
Next.js
Static vs dynamic rendering in the App Router: what makes a route dynamic?
#nextjs#rendering#static
Next.js
`next/link` prefetching: what does it do and how can you control it?
#nextjs#link#prefetch
Next.js
Middleware in Next.js: what is it good for and what are its limitations?
#nextjs#middleware#edge
Next.js
Cache invalidation: what do `revalidatePath` and `revalidateTag` do?
#nextjs#cache#revalidate
Next.js
Dynamic routes: what does `generateStaticParams` do?
#nextjs#ssg#dynamic-routes