@payload-auth-link/web
v0.2.2
Published
payload-auth-link framework-free web-adapter toolkit: route handlers, session verification, server authorization, redirect safety.
Readme
@payload-auth-link/web
The framework-free web layer shared by the Next.js and TanStack Start adapters: auth route handlers, server-side session verification, server authorization, and redirect safety, all on the standard Request and Headers. Both adapters re-export it in full, so import from your framework adapter unless you're building one.
Part of payload-auth-link: an auth plugin for Payload CMS with swappable identity providers (Better Auth, Auth.js) and first-class Next.js and TanStack Start adapters.
Install
npm install @payload-auth-link/webESM-only, Node 20.9 or later.
What it provides
createSessionVerifier: full session validation against the plugin's session endpoint, anchored to yourbaseUrlrequireSessionUser,requireRoles: server-side enforcement that runs before protected content renderscreateRouteHandlers: mount the identity provider's routesdecideAuthRedirect,safeRedirectPath: the optimistic bounce and post-login destination safety
Usage
import { createSessionVerifier, requireRoles } from '@payload-auth-link/web'
const verify = createSessionVerifier({ baseUrl: 'https://example.com' })
const admin = await requireRoles(request.headers, verify, { roles: ['admin'] })Docs
License
MIT
