API Handlers
Pre-built handlers for OAuth authentication endpoints in Next.js API routes.
Overview
AuthSafe provides ready-to-use handlers for all authentication flows: handleSignIn to initiate OAuth sign in, handleCallback to process OAuth callback, handleLogout to sign out and clear session, and handleRefresh to refresh tokens. All handlers are compatible with both App Router and Pages Router.
Basic Usage
// app/api/auth/...authsafe/route.ts
import {
handleSignIn,
handleCallback,
handleLogout,
handleRefresh,
} from 'authsafe-nextjs/server';
export const GET = handleSignIn;
export const POST = handleCallback;