Skip to content

API Reference

The @saas template exposes HTTP endpoints via Next.js Route Handlers and server-side logic via Server Actions.

Base URL

All route handler endpoints are relative to your deployed Next.js app URL. Configure the base URL in the interactive playground below.

Endpoints

Health

MethodPathDescription
GET/api/healthHealth check — returns { status: "ok" }

Auth (NextAuth v5)

MethodPathDescription
GET/api/auth/sessionGet current session
POST/api/auth/signinSign in with credentials
POST/api/auth/signoutSign out
GET/api/auth/callback/:providerOAuth callback (Google, GitHub)
GET/api/auth/csrfCSRF token for forms

Demo Endpoints (installed with modules)

MethodPathModuleDescription
GET/api/demo/landing@saas/landingLanding page API demo
GET/api/demo/admin/users@saas/adminAdmin users list demo

Interactive Playground

Configure your deployed Next.js app URL below, then send real HTTP requests:

GET/api/health
Base URL (your deployed Next.js app)
Authorization Header (optional)
Try in Live App →

Server Actions

Server Actions are not cross-origin callable. They are invoked directly from React components on the server. For cross-origin access, use the route handler endpoints above.

ActionModuleDescription
updateProfile()@saas/accountUpdate user display name
changePassword()@saas/accountChange password (requires current password)
deleteAccount()@saas/accountDelete own account (danger zone)
listUsers()@saas/adminList all users (admin only)
updateUserRole()@saas/adminChange a user's role (admin only)
deleteUser()@saas/adminDelete a user (admin only)

To test Server Actions interactively, use the Live Demo which is the deployed Next.js app.

Authentication

Most endpoints require a valid NextAuth session. The session cookie is set automatically when you sign in.

For the API playground, enter your session token in the Authorization field:

  1. Sign in at GET /api/auth/session to inspect your session
  2. Use POST /api/auth/signin with { email, password } to get a session cookie
  3. Subsequent requests will use the session cookie automatically (for same-origin requests)

Note: Cross-origin requests from this docs site will not automatically carry session cookies. Configure CORS on your Next.js app or use the Live Demo for full interactive testing.

Released under the MIT License.