Skip to content

handlers

auth.handlers returns { GET, POST } — a pair of Next.js route handler functions for a catch-all route.

Usage

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

Routing

The handlers dispatch based on the last URL segment:

MethodSegmentAction
GETmeReturn current user from JWT cookie
POSTloginValidate credentials, sign JWT, set cookie
POSTlogoutClear auth cookie

Signature

ts
type Handlers = {
  GET: (req: NextRequest) => Promise<NextResponse>;
  POST: (req: NextRequest) => Promise<NextResponse>;
};

Released under the MIT License.