@duongtrungnguyen/next-helper
Version:
Helper library for Next.js 15
33 lines • 1.77 kB
TypeScript
import { FC, ReactNode } from "react";
import type { ProtectProps } from "./types";
type SignedInProps = {
children: ReactNode;
};
/**
* A server-side component that renders its children only if the user is signed in.
*
* @param {SignedInProps} props - The properties for the SignedIn component.
* @param {React.ReactNode} props.children - The child elements to render if the user is signed in.
* @returns {Promise<JSX.Element | null>} A promise that resolves to the child elements if the user is signed in, or null if the user is not signed in.
*/
export declare const SignedIn: FC<SignedInProps>;
/**
* A React functional component that renders its children only if the user is signed out.
*
* @param {SignedInProps} props - The properties passed to the component.
* @param {React.ReactNode} props.children - The child elements to be rendered if the user is signed out.
* @returns {Promise<JSX.Element | null>} - A promise that resolves to the child elements if the user is signed out, otherwise null.
*/
export declare const SignedOut: FC<SignedInProps>;
/**
* Protect component to conditionally render children based on authentication status.
*
* @param {ProtectProps} props - The properties for the Protect component.
* @param {React.ReactNode} props.children - The content to render if the user is authenticated.
* @param {React.ReactNode} [props.fallback] - The content to render if the user is not authenticated.
* @param {any} props.condition - The condition to check for authentication.
* @returns {Promise<JSX.Element | null>} - The authorized content if the user is authenticated, otherwise the fallback content or null.
*/
export declare const Protect: FC<ProtectProps>;
export {};
//# sourceMappingURL=server-components.d.ts.map