UNPKG

payload-authjs

Version:
31 lines (30 loc) 1.36 kB
import type { CollectionSlug, DataFromCollectionSlug } from "payload"; import type { AUTHJS_STRATEGY_NAME } from "../AuthjsAuthStrategy"; interface Options<TSlug extends CollectionSlug> { /** * The slug of the collection that contains the users * * @default "users" */ userCollectionSlug?: TSlug; } export interface PayloadSession<TSlug extends CollectionSlug> { user: { collection?: CollectionSlug; _strategy?: typeof AUTHJS_STRATEGY_NAME | "local-jwt" | "api-key" | ({} & string); } & DataFromCollectionSlug<TSlug>; expires: string; collection?: CollectionSlug; strategy?: typeof AUTHJS_STRATEGY_NAME | "local-jwt" | "api-key" | ({} & string); } /** * Get the payload session from the server-side * * This function is cached to de-duplicate requests: * - using React 'cache' function to memorize within the same request (@see https://react.dev/reference/react/cache) * - and using Next.js 'data cache' to cache across multiple requests (@see https://nextjs.org/docs/app/building-your-application/caching#data-cache) * * You can manually invalidate the cache by calling `revalidateTag("payload-session")` */ export declare const getPayloadSession: <TSlug extends CollectionSlug = "users">({ userCollectionSlug, }?: Options<TSlug>) => Promise<PayloadSession<TSlug> | null>; export {};