Documentation

API call

App Router API routes make it easy to wire new endpoints with full access to Prisma, Stripe helpers, and NextAuth sessions.

Model a route

Place a `route.ts` file under `src/app/api/{resource}`. Use `NextResponse` for structured JSON, and reach for `getServerSession(authOptions)` whenever the handler needs to know who is calling.

Relevant files

  • src/app/api/support/route.ts — Support API example

Share business helpers

Stripe utilities, Prisma client, and plan lookups already live in `src/lib`. Import them directly inside the API route so everything stays type-safe and centralized.

Relevant files

  • src/lib/stripe.ts — Stripe helpers
  • src/lib/db.ts — Prisma client

Surface data in the UI

Client components fetch with `fetch('/api/...')` as shown in `src/components/site-header.tsx`, or server components can call the underlying function directly for better performance.

Relevant files

  • src/components/site-header.tsx — Plan badge fetch