UNPKG

payload-authjs

Version:
32 lines (31 loc) 1.38 kB
import type { DataFromCollectionSlug } from "payload"; import type { AUTHJS_STRATEGY_NAME } from "../../constants"; import type { AuthCollectionSlug } from "../plugin"; interface Options<TSlug extends AuthCollectionSlug> { /** * The slug of the collection that contains the users * * @default "users" */ userCollectionSlug?: TSlug; } export interface PayloadSession<TSlug extends AuthCollectionSlug> { user: { collection?: TSlug; _strategy?: typeof AUTHJS_STRATEGY_NAME | "local-jwt" | "api-key" | ({} & string); } & DataFromCollectionSlug<TSlug>; expires?: string; collection?: TSlug; 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 AuthCollectionSlug = "users">({ userCollectionSlug, }?: Options<TSlug>) => Promise<PayloadSession<TSlug> | null>; export {};