@payload-auth-link/tanstack-start
v0.2.1
Published
payload-auth-link TanStack Start adapter: server routes, request middleware, session server functions, hydration.
Readme
@payload-auth-link/tanstack-start
The TanStack Start adapter (Payload v4): server-route handlers, request middleware, session server-function helpers, route-loader hydration, and a client refresh hook. It re-exports the whole framework-free @payload-auth-link/web surface.
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/tanstack-startPeer dependencies: @tanstack/react-router ^1.170.0, @tanstack/react-start ^1.140.2, react ^19.0.0.
ESM-only, Node 20.9 or later.
What it provides
createServerRouteHandlers: mount the identity provider's routes inserver.handlerscreateAuthRequestMiddleware: the optimistic bounce forsrc/start.ts(exempts server functions by default)getSessionUserFromRequest,createSessionLoader: server-side reads and root-loader hydrationuseAuthLinkRefreshStart: re-reads the session and invalidates loaders after auth changes- Everything from
@payload-auth-link/web
Usage
// src/start.ts
import { createAuthRequestMiddleware } from '@payload-auth-link/tanstack-start'
export const authMiddleware = createAuthRequestMiddleware({
sessionCookieNames: ['better-auth.session_token'],
})Docs
License
MIT
