Skip to content

Route Handlers

A single catch-all route file handles all auth endpoints automatically.

Setup

ts
// app/api/auth/[...liteauth]/route.ts
import { handlers } from "@/auth";
export const { GET, POST } = handlers;

Endpoints

MethodPathDescription
POST/api/auth/loginValidate credentials, sign JWT, set cookie
POST/api/auth/logoutClear the auth cookie
GET/api/auth/meReturn the current user from cookie

POST /api/auth/login

Request body:

json
{ "email": "user@example.com", "password": "secret" }

Success (200):

json
{ "user": { "email": "user@example.com", "name": "User", "role": "user" } }

Error (401):

json
{ "error": "Invalid credentials" }

POST /api/auth/logout

Success (200):

json
{ "ok": true }

GET /api/auth/me

Success (200):

json
{ "user": { "email": "user@example.com", "name": "User", "role": "user" } }

Unauthenticated (401):

json
{ "user": null }

Released under the MIT License.