/*! * ======================================================================== * @rzl-zone/next-kit * ------------------------------------------------------------------------ * Version: `0.10.4` * Author: `Rizalvin Dwiky ` * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/next-kit` * ======================================================================== */ import { ReactNode } from "react"; interface PageContextProps { /** Defaults to `merge`. */ strategy?: PageContextStrategy; data?: T; children: ReactNode; } interface Context { [key: string]: unknown; } type PageContextStrategy = "deepmerge" | "merge"; declare global { interface Window { __next_c?: [PageContextStrategy, { data: Context; }][]; } } /** ------------------------------------------------------------------- * * ***A component that provides context data to its children (can be use in server component).*** * ------------------------------------------------------------------- * * ***`⚠️ Warning: Currently is not support with turbopack flag mode !!!`*** * ------------------------------------------------------------------- * @param props - The properties for the PageContextProvider component. * @returns A JSX element that provides the context to its children. * * @example * ```tsx * import { PageContext } from "@rzl-zone/next-kit/extra/context"; * * export default async function Layout({ children }: { children: ReactNode }) { * // ... * * return ( * * {children} * * ); * } * ``` */ declare function PageContextProvider(props: PageContextProps): import("react").JSX.Element; /** Alias for `PageContextProvider`. */ /** ------------------------------------------------------------------- * * ***This hook uses the shared context from the adjacent server layout within the `PageContextProvider` component.*** * ------------------------------------------------------------------- * * ***`⚠️ Warning: Currently is not support with turbopack flag mode !!!`*** * ------------------------------------------------------------------- * @example * ```tsx * "use client"; * * import { usePageContext } from "@rzl-zone/next-kit/extra/context"; * * export default function Page() { * const ctx = usePageContext<{ name: string }>(); * * return ( * //... * ); * } * ``` */ declare function usePageContext(): Readonly; /** ------------------------------------------------------------------- * * ***This hook uses the shared context from the client-side browser window. the context is only*** * ***available on *client-side* after hydration.*** * ------------------------------------------------------------------- * * ***`⚠️ Warning: Currently is not support with turbopack flag mode !!!`*** * ------------------------------------------------------------------- * @example * ```tsx * "use client"; * * import { useServerInsertedContext } from "@rzl-zone/next-kit/extra/context"; * * export default function Page() { * const ctx = useServerInsertedContext<{ name: string }>(); * * return ( * //... * ); * } * ``` */ declare function useServerInsertedContext(): Readonly; export { Context, PageContextProvider as PageContext, PageContextProps, PageContextStrategy, usePageContext, useServerInsertedContext };