import * as react_jsx_runtime from 'react/jsx-runtime'; import { InsforgeProviderProps, useInsforge as useInsforge$1 } from '@insforge/react'; export { InitialAuthState } from '@insforge/react'; /** * Props for InsforgeBrowserProvider */ type InsforgeBrowserProviderProps = InsforgeProviderProps; /** * Browser-side Insforge Provider for Next.js * * This provider manages authentication state on the client side and automatically * syncs tokens to HTTP-only cookies via `/api/auth` route for server-side access. * * **Key Features:** * - Uses YOUR SDK client instance (shared with database/storage operations) * - Automatic token sync to HTTP-only cookies * - SSR hydration support via `initialState` * - Works with Next.js App Router * * --- * * ## Setup Guide * * ### Step 1: Create your SDK client * * @example * ```tsx * // lib/insforge.ts * import { createClient } from '@insforge/sdk'; * * export const insforge = createClient({ * baseUrl: process.env.NEXT_PUBLIC_INSFORGE_URL!, * anonKey: process.env.NEXT_PUBLIC_INSFORGE_ANON_KEY!, * }); * ``` * * ### Step 2: Create your Providers component * * @example * ```tsx * // app/providers.tsx * 'use client'; * import { InsforgeBrowserProvider, type InitialAuthState } from '@insforge/nextjs'; * import { insforge } from '@/lib/insforge'; * * export function Providers({ * children, * }: { * children: React.ReactNode; * }) { * return ( * * {children} * * ); * } * ``` * * ### Step 3: Use in your root layout * * @example * ```tsx * // app/layout.tsx * import { getAuthFromCookies } from '@insforge/nextjs'; * import { Providers } from './providers'; * * export default async function RootLayout({ * children, * }: { * children: React.ReactNode; * }) { * const initialState = await getAuthFromCookies(); * * return ( * * * * {children} * * * * ); * } * ``` * * ### Step 4: Use auth components and hooks * * @example * ```tsx * // app/page.tsx * 'use client'; * import { SignIn, UserButton, useInsforge } from '@insforge/nextjs'; * * export default function Page() { * const { isSignedIn, user } = useInsforge(); * * if (!isSignedIn) return ; * * return ( *
* *

Welcome {user?.email}

*
* ); * } * ``` * * --- * * ## Why pass your own client? * * Authentication tokens are stored in the SDK client instance's memory. * If auth components use a different client than your app, they won't share * tokens, causing authentication to fail for database/storage operations. * * By passing YOUR client to the provider, all operations use the same * authenticated session. */ declare function InsforgeBrowserProvider({ children, client, afterSignInUrl, onAuthChange, initialState, }: InsforgeBrowserProviderProps): react_jsx_runtime.JSX.Element; /** * @deprecated Use `InsforgeBrowserProvider` instead. * * This alias is kept for backward compatibility and will be removed in a future version. * * Migration: * ```tsx * // Before * import { ClientInsforgeProvider } from '@insforge/nextjs'; * * // After * import { InsforgeBrowserProvider } from '@insforge/nextjs'; * ``` */ declare const ClientInsforgeProvider: typeof InsforgeBrowserProvider; /** * Hook to access Insforge context * * Re-exports the hook from @insforge/react for convenience. * * @example * ```tsx * function MyComponent() { * const { user, isSignedIn, signOut } = useInsforge(); * * if (!isSignedIn) return ; * * return ( *
*

Welcome {user.email}

* *
* ); * } * ``` */ declare const useInsforge: typeof useInsforge$1; export { ClientInsforgeProvider, InsforgeBrowserProvider, type InsforgeBrowserProviderProps, useInsforge };