payload-authjs
Version:
A Payload CMS 3 plugin for Auth.js 5
46 lines (45 loc) • 1.46 kB
TypeScript
import { type ReactNode } from "react";
import type { AuthCollectionSlug } from "../plugin";
import type { PayloadSession } from "./getPayloadSession";
export interface PayloadSessionContext<TSlug extends AuthCollectionSlug = AuthCollectionSlug> {
/**
* The status of the session
*/
status: "loading" | "authenticated" | "unauthenticated";
/**
* The session
*/
session: PayloadSession<TSlug> | null;
/**
* Function to refresh the session
*/
refresh: () => Promise<PayloadSession<TSlug> | null>;
/**
* Function to refetch the session from the server
*/
refetch: () => Promise<PayloadSession<TSlug> | null>;
}
export declare const Context: import("react").Context<PayloadSessionContext<"users-with-local-strategy" | "users">>;
interface Props<TSlug extends AuthCollectionSlug> {
/**
* The slug of the collection that contains the users
*
* @default "users"
*/
userCollectionSlug?: TSlug;
/**
* The session from the server
*
* @default null
*/
session?: PayloadSession<TSlug> | null;
/**
* The children to render
*/
children: ReactNode;
}
/**
* PayloadSessionProvider that provides the session to the context provider
*/
export declare const PayloadSessionProvider: <TSlug extends AuthCollectionSlug = "users">({ userCollectionSlug, session, children, }: Props<TSlug>) => import("react").JSX.Element;
export {};