API patterns
Next.js route handlers, Server Actions, TanStack Query, validation with Zod, and protected endpoints.
Recommendation
Simulacrum standardizes on Server Actions for mutations and TanStack Query for client fetching instead of bolting Hono and oRPC onto every template. This keeps stacks idiomatic for Next.js while preserving type safety end to end.
Route handlers
Use app/api/**/route.ts for webhooks, public JSON endpoints, and third-party callbacks. Apply auth helpers before returning data.
Server Actions
Define actions in server modules with "use server". Validate input with Zod and return discriminated unions for errors the UI can render.
TanStack Query
Wrap fetches in hooks with stable query keys. Invalidate after successful mutations.
OpenAPI
Optional OpenAPI generation can document public REST surfaces; keep generated specs in CI when you expose partner APIs.
Mirror authorization checks used in UI routes inside every action and API handler.