@insforge/nextjs 1.0.5-dev.7 → 1.0.5-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import * as _insforge_shared_schemas from '@insforge/shared-schemas';
2
2
  import { CreateSessionResponse, CreateUserResponse } from '@insforge/shared-schemas';
3
- import * as _insforge_react from '@insforge/react';
3
+ import { InsforgeUser } from '@insforge/shared';
4
4
 
5
5
  /**
6
6
  * Next.js specific hooks - implemented locally to avoid Context duplication
@@ -17,7 +17,7 @@ declare function useAuth(): {
17
17
  isSignedIn: boolean | undefined;
18
18
  };
19
19
  declare function useUser(): {
20
- user: _insforge_react.InsforgeUser | null | undefined;
20
+ user: InsforgeUser | null | undefined;
21
21
  isLoaded: boolean;
22
22
  };
23
23
  declare function usePublicAuthConfig(): {
@@ -72,15 +72,12 @@ interface InsforgeBrowserProviderProps extends InsforgeProviderProps {
72
72
  *
73
73
  * export function Providers({
74
74
  * children,
75
- * initialState,
76
75
  * }: {
77
76
  * children: React.ReactNode;
78
- * initialState?: InitialAuthState;
79
77
  * }) {
80
78
  * return (
81
79
  * <InsforgeBrowserProvider
82
80
  * client={insforge}
83
- * initialState={initialState}
84
81
  * afterSignInUrl="/dashboard"
85
82
  * >
86
83
  * {children}
@@ -94,7 +91,7 @@ interface InsforgeBrowserProviderProps extends InsforgeProviderProps {
94
91
  * @example
95
92
  * ```tsx
96
93
  * // app/layout.tsx
97
- * import { getAuthFromCookies } from '@insforge/nextjs/server';
94
+ * import { getAuthFromCookies } from '@insforge/nextjs';
98
95
  * import { Providers } from './providers';
99
96
  *
100
97
  * export default async function RootLayout({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/hooks.ts"],"sourcesContent":["'use client';\n\nimport { useInsforge } from './provider';\nimport { CreateSessionResponse, CreateUserResponse } from '@insforge/shared-schemas';\n\n/**\n * Next.js specific hooks - implemented locally to avoid Context duplication\n */\n\nexport function useAuth(): {\n signIn: (email: string, password: string) => Promise<CreateSessionResponse | { error?: string }>;\n signUp: (email: string, password: string) => Promise<CreateUserResponse | { error?: string }>;\n signOut: () => Promise<void>;\n isLoaded: boolean;\n isSignedIn: boolean | undefined;\n} {\n const { signIn, signUp, signOut, isLoaded, isSignedIn } = useInsforge();\n return { signIn, signUp, signOut, isLoaded, isSignedIn };\n}\n\nexport function useUser() {\n const { user, isLoaded } = useInsforge();\n return { user, isLoaded };\n}\n\nexport function usePublicAuthConfig() {\n const { getPublicAuthConfig } = useInsforge();\n return { getPublicAuthConfig };\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAOrB,SAAS,UAMd;AACA,QAAM,EAAE,QAAQ,QAAQ,SAAS,UAAU,WAAW,IAAI,YAAY;AACtE,SAAO,EAAE,QAAQ,QAAQ,SAAS,UAAU,WAAW;AACzD;AAEO,SAAS,UAAU;AACxB,QAAM,EAAE,MAAM,SAAS,IAAI,YAAY;AACvC,SAAO,EAAE,MAAM,SAAS;AAC1B;AAEO,SAAS,sBAAsB;AACpC,QAAM,EAAE,oBAAoB,IAAI,YAAY;AAC5C,SAAO,EAAE,oBAAoB;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/hooks.ts"],"sourcesContent":["'use client';\n\nimport { useInsforge } from './provider';\nimport { CreateSessionResponse, CreateUserResponse } from '@insforge/shared-schemas';\nimport type { InsforgeUser } from '@insforge/shared';\n\n/**\n * Next.js specific hooks - implemented locally to avoid Context duplication\n */\n\nexport function useAuth(): {\n signIn: (email: string, password: string) => Promise<CreateSessionResponse | { error?: string }>;\n signUp: (email: string, password: string) => Promise<CreateUserResponse | { error?: string }>;\n signOut: () => Promise<void>;\n isLoaded: boolean;\n isSignedIn: boolean | undefined;\n} {\n const { signIn, signUp, signOut, isLoaded, isSignedIn } = useInsforge();\n return { signIn, signUp, signOut, isLoaded, isSignedIn };\n}\n\nexport function useUser(): {\n user: InsforgeUser | null | undefined;\n isLoaded: boolean;\n} {\n const { user, isLoaded } = useInsforge();\n return { user, isLoaded };\n}\n\nexport function usePublicAuthConfig() {\n const { getPublicAuthConfig } = useInsforge();\n return { getPublicAuthConfig };\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAQrB,SAAS,UAMd;AACA,QAAM,EAAE,QAAQ,QAAQ,SAAS,UAAU,WAAW,IAAI,YAAY;AACtE,SAAO,EAAE,QAAQ,QAAQ,SAAS,UAAU,WAAW;AACzD;AAEO,SAAS,UAGd;AACA,QAAM,EAAE,MAAM,SAAS,IAAI,YAAY;AACvC,SAAO,EAAE,MAAM,SAAS;AAC1B;AAEO,SAAS,sBAAsB;AACpC,QAAM,EAAE,oBAAoB,IAAI,YAAY;AAC5C,SAAO,EAAE,oBAAoB;AAC/B;","names":[]}
@@ -44,7 +44,7 @@ function InsforgeBrowserProvider({
44
44
  client,
45
45
  afterSignInUrl = "/",
46
46
  onAuthChange,
47
- initialState
47
+ initialState = { user: null, userId: null }
48
48
  }) {
49
49
  const providerProps = {
50
50
  children,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/provider.tsx"],"sourcesContent":["'use client';\n\nimport {\n InsforgeProviderCore,\n type InsforgeProviderProps,\n type InitialAuthState,\n useInsforge as useReactInsforge,\n NavigationProvider,\n StyleProvider,\n} from '@insforge/react';\nimport { NavigationAdapter } from '../navigation';\nimport type { InsForgeClient } from '@insforge/sdk';\n\n/**\n * Props for InsforgeBrowserProvider\n */\nexport interface InsforgeBrowserProviderProps extends InsforgeProviderProps {\n children: React.ReactNode;\n /**\n * The InsForge SDK client instance.\n * \n * **Important:** Use the same client instance that you use for database,\n * storage, and other SDK operations. This ensures authentication tokens\n * are shared correctly.\n */\n client: InsForgeClient;\n /**\n * URL to redirect to after successful sign in\n * @default '/'\n */\n afterSignInUrl?: string;\n /**\n * Callback when auth state changes\n */\n onAuthChange?: (user: any) => void;\n /**\n * Initial auth state from server (for SSR hydration).\n * Get this using `getAuthFromCookies()`.\n */\n initialState?: InitialAuthState;\n}\n\n// Sync token to server-side cookie using Authorization header\nasync function syncTokenToCookie(token: string): Promise<void> {\n try {\n const response = await fetch('/api/auth', {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n action: 'sync-token',\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n console.error('[InsforgeBrowserProvider] sync-token failed:', errorText);\n }\n } catch (err) {\n console.error('[InsforgeBrowserProvider] Failed to sync token to cookie:', err);\n }\n}\n\n// Sync token to server-side cookie on sign in\nasync function handleSignIn(token: string): Promise<void> {\n await syncTokenToCookie(token);\n}\n\n// Sync token to server-side cookie on refresh (page load/refresh)\nasync function handleRefresh(token: string): Promise<void> {\n await syncTokenToCookie(token);\n}\n\n// Clear HTTP-only cookie on sign out\nasync function handleSignOut(): Promise<void> {\n try {\n await fetch('/api/auth', { method: 'DELETE' });\n } catch {\n // API route doesn't exist - ignore\n }\n}\n\n/**\n * Browser-side Insforge Provider for Next.js\n *\n * This provider manages authentication state on the client side and automatically\n * syncs tokens to HTTP-only cookies via `/api/auth` route for server-side access.\n *\n * **Key Features:**\n * - Uses YOUR SDK client instance (shared with database/storage operations)\n * - Automatic token sync to HTTP-only cookies\n * - SSR hydration support via `initialState`\n * - Works with Next.js App Router\n *\n * ---\n *\n * ## Setup Guide\n *\n * ### Step 1: Create your SDK client\n *\n * @example\n * ```tsx\n * // lib/insforge.ts\n * 'use client';\n * import { createClient } from '@insforge/sdk';\n *\n * export const insforge = createClient({\n * baseUrl: process.env.NEXT_PUBLIC_INSFORGE_URL!,\n * anonKey: process.env.NEXT_PUBLIC_INSFORGE_ANON_KEY!,\n * });\n * ```\n *\n * ### Step 2: Create your Providers component\n *\n * @example\n * ```tsx\n * // app/providers.tsx\n * 'use client';\n * import { InsforgeBrowserProvider, type InitialAuthState } from '@insforge/nextjs';\n * import { insforge } from '@/lib/insforge';\n *\n * export function Providers({\n * children,\n * initialState,\n * }: {\n * children: React.ReactNode;\n * initialState?: InitialAuthState;\n * }) {\n * return (\n * <InsforgeBrowserProvider\n * client={insforge}\n * initialState={initialState}\n * afterSignInUrl=\"/dashboard\"\n * >\n * {children}\n * </InsforgeBrowserProvider>\n * );\n * }\n * ```\n *\n * ### Step 3: Use in your root layout\n *\n * @example\n * ```tsx\n * // app/layout.tsx\n * import { getAuthFromCookies } from '@insforge/nextjs/server';\n * import { Providers } from './providers';\n *\n * export default async function RootLayout({\n * children,\n * }: {\n * children: React.ReactNode;\n * }) {\n * const initialState = await getAuthFromCookies();\n *\n * return (\n * <html>\n * <body>\n * <Providers initialState={initialState}>\n * {children}\n * </Providers>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * ### Step 4: Use auth components and hooks\n *\n * @example\n * ```tsx\n * // app/page.tsx\n * 'use client';\n * import { SignIn, UserButton, useInsforge } from '@insforge/nextjs';\n *\n * export default function Page() {\n * const { isSignedIn, user } = useInsforge();\n *\n * if (!isSignedIn) return <SignIn />;\n *\n * return (\n * <div>\n * <UserButton />\n * <p>Welcome {user?.email}</p>\n * </div>\n * );\n * }\n * ```\n *\n * ---\n *\n * ## Why pass your own client?\n *\n * Authentication tokens are stored in the SDK client instance's memory.\n * If auth components use a different client than your app, they won't share\n * tokens, causing authentication to fail for database/storage operations.\n *\n * By passing YOUR client to the provider, all operations use the same\n * authenticated session.\n */\nexport function InsforgeBrowserProvider({\n children,\n client,\n afterSignInUrl = '/',\n onAuthChange,\n initialState,\n}: InsforgeBrowserProviderProps) {\n const providerProps: InsforgeProviderProps = {\n children,\n client,\n afterSignInUrl,\n onAuthChange,\n onSignIn: handleSignIn,\n onSignOut: handleSignOut,\n onRefresh: handleRefresh,\n initialState,\n };\n\n return (\n <StyleProvider>\n <NavigationProvider adapter={NavigationAdapter}>\n <InsforgeProviderCore {...providerProps}>{children}</InsforgeProviderCore>\n </NavigationProvider>\n </StyleProvider>\n );\n}\n\n/**\n * @deprecated Use `InsforgeBrowserProvider` instead.\n *\n * This alias is kept for backward compatibility and will be removed in a future version.\n *\n * Migration:\n * ```tsx\n * // Before\n * import { ClientInsforgeProvider } from '@insforge/nextjs';\n *\n * // After\n * import { InsforgeBrowserProvider } from '@insforge/nextjs';\n * ```\n */\nexport const ClientInsforgeProvider = InsforgeBrowserProvider;\n\n/**\n * Hook to access Insforge context\n *\n * Re-exports the hook from @insforge/react for convenience.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { user, isSignedIn, signOut } = useInsforge();\n *\n * if (!isSignedIn) return <SignIn />;\n *\n * return (\n * <div>\n * <p>Welcome {user.email}</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport const useInsforge = useReactInsforge;\n\n// Re-export types\nexport type { InitialAuthState };\n"],"mappings":";AA+NQ;AA7NR;AAAA,EACE;AAAA,EAGA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAiClC,eAAe,kBAAkB,OAA8B;AAC7D,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,aAAa;AAAA,MACxC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK;AAAA,QAC9B,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB,QAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,cAAQ,MAAM,gDAAgD,SAAS;AAAA,IACzE;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,6DAA6D,GAAG;AAAA,EAChF;AACF;AAGA,eAAe,aAAa,OAA8B;AACxD,QAAM,kBAAkB,KAAK;AAC/B;AAGA,eAAe,cAAc,OAA8B;AACzD,QAAM,kBAAkB,KAAK;AAC/B;AAGA,eAAe,gBAA+B;AAC5C,MAAI;AACF,UAAM,MAAM,aAAa,EAAE,QAAQ,SAAS,CAAC;AAAA,EAC/C,QAAQ;AAAA,EAER;AACF;AAwHO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AACF,GAAiC;AAC/B,QAAM,gBAAuC;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,EACF;AAEA,SACE,oBAAC,iBACC,8BAAC,sBAAmB,SAAS,mBAC3B,8BAAC,wBAAsB,GAAG,eAAgB,UAAS,GACrD,GACF;AAEJ;AAgBO,MAAM,yBAAyB;AAuB/B,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/provider.tsx"],"sourcesContent":["'use client';\n\nimport {\n InsforgeProviderCore,\n type InsforgeProviderProps,\n type InitialAuthState,\n useInsforge as useReactInsforge,\n NavigationProvider,\n StyleProvider,\n} from '@insforge/react';\nimport { NavigationAdapter } from '../navigation';\nimport type { InsForgeClient } from '@insforge/sdk';\n\n/**\n * Props for InsforgeBrowserProvider\n */\nexport interface InsforgeBrowserProviderProps extends InsforgeProviderProps {\n children: React.ReactNode;\n /**\n * The InsForge SDK client instance.\n * \n * **Important:** Use the same client instance that you use for database,\n * storage, and other SDK operations. This ensures authentication tokens\n * are shared correctly.\n */\n client: InsForgeClient;\n /**\n * URL to redirect to after successful sign in\n * @default '/'\n */\n afterSignInUrl?: string;\n /**\n * Callback when auth state changes\n */\n onAuthChange?: (user: any) => void;\n /**\n * Initial auth state from server (for SSR hydration).\n * Get this using `getAuthFromCookies()`.\n */\n initialState?: InitialAuthState;\n}\n\n// Sync token to server-side cookie using Authorization header\nasync function syncTokenToCookie(token: string): Promise<void> {\n try {\n const response = await fetch('/api/auth', {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n action: 'sync-token',\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n console.error('[InsforgeBrowserProvider] sync-token failed:', errorText);\n }\n } catch (err) {\n console.error('[InsforgeBrowserProvider] Failed to sync token to cookie:', err);\n }\n}\n\n// Sync token to server-side cookie on sign in\nasync function handleSignIn(token: string): Promise<void> {\n await syncTokenToCookie(token);\n}\n\n// Sync token to server-side cookie on refresh (page load/refresh)\nasync function handleRefresh(token: string): Promise<void> {\n await syncTokenToCookie(token);\n}\n\n// Clear HTTP-only cookie on sign out\nasync function handleSignOut(): Promise<void> {\n try {\n await fetch('/api/auth', { method: 'DELETE' });\n } catch {\n // API route doesn't exist - ignore\n }\n}\n\n/**\n * Browser-side Insforge Provider for Next.js\n *\n * This provider manages authentication state on the client side and automatically\n * syncs tokens to HTTP-only cookies via `/api/auth` route for server-side access.\n *\n * **Key Features:**\n * - Uses YOUR SDK client instance (shared with database/storage operations)\n * - Automatic token sync to HTTP-only cookies\n * - SSR hydration support via `initialState`\n * - Works with Next.js App Router\n *\n * ---\n *\n * ## Setup Guide\n *\n * ### Step 1: Create your SDK client\n *\n * @example\n * ```tsx\n * // lib/insforge.ts\n * 'use client';\n * import { createClient } from '@insforge/sdk';\n *\n * export const insforge = createClient({\n * baseUrl: process.env.NEXT_PUBLIC_INSFORGE_URL!,\n * anonKey: process.env.NEXT_PUBLIC_INSFORGE_ANON_KEY!,\n * });\n * ```\n *\n * ### Step 2: Create your Providers component\n *\n * @example\n * ```tsx\n * // app/providers.tsx\n * 'use client';\n * import { InsforgeBrowserProvider, type InitialAuthState } from '@insforge/nextjs';\n * import { insforge } from '@/lib/insforge';\n *\n * export function Providers({\n * children,\n * }: {\n * children: React.ReactNode;\n * }) {\n * return (\n * <InsforgeBrowserProvider\n * client={insforge}\n * afterSignInUrl=\"/dashboard\"\n * >\n * {children}\n * </InsforgeBrowserProvider>\n * );\n * }\n * ```\n *\n * ### Step 3: Use in your root layout\n *\n * @example\n * ```tsx\n * // app/layout.tsx\n * import { getAuthFromCookies } from '@insforge/nextjs';\n * import { Providers } from './providers';\n *\n * export default async function RootLayout({\n * children,\n * }: {\n * children: React.ReactNode;\n * }) {\n * const initialState = await getAuthFromCookies();\n *\n * return (\n * <html>\n * <body>\n * <Providers initialState={initialState}>\n * {children}\n * </Providers>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * ### Step 4: Use auth components and hooks\n *\n * @example\n * ```tsx\n * // app/page.tsx\n * 'use client';\n * import { SignIn, UserButton, useInsforge } from '@insforge/nextjs';\n *\n * export default function Page() {\n * const { isSignedIn, user } = useInsforge();\n *\n * if (!isSignedIn) return <SignIn />;\n *\n * return (\n * <div>\n * <UserButton />\n * <p>Welcome {user?.email}</p>\n * </div>\n * );\n * }\n * ```\n *\n * ---\n *\n * ## Why pass your own client?\n *\n * Authentication tokens are stored in the SDK client instance's memory.\n * If auth components use a different client than your app, they won't share\n * tokens, causing authentication to fail for database/storage operations.\n *\n * By passing YOUR client to the provider, all operations use the same\n * authenticated session.\n */\nexport function InsforgeBrowserProvider({\n children,\n client,\n afterSignInUrl = '/',\n onAuthChange,\n initialState = { user: null, userId: null },\n}: InsforgeBrowserProviderProps) {\n const providerProps: InsforgeProviderProps = {\n children,\n client,\n afterSignInUrl,\n onAuthChange,\n onSignIn: handleSignIn,\n onSignOut: handleSignOut,\n onRefresh: handleRefresh,\n initialState,\n };\n\n return (\n <StyleProvider>\n <NavigationProvider adapter={NavigationAdapter}>\n <InsforgeProviderCore {...providerProps}>{children}</InsforgeProviderCore>\n </NavigationProvider>\n </StyleProvider>\n );\n}\n\n/**\n * @deprecated Use `InsforgeBrowserProvider` instead.\n *\n * This alias is kept for backward compatibility and will be removed in a future version.\n *\n * Migration:\n * ```tsx\n * // Before\n * import { ClientInsforgeProvider } from '@insforge/nextjs';\n *\n * // After\n * import { InsforgeBrowserProvider } from '@insforge/nextjs';\n * ```\n */\nexport const ClientInsforgeProvider = InsforgeBrowserProvider;\n\n/**\n * Hook to access Insforge context\n *\n * Re-exports the hook from @insforge/react for convenience.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { user, isSignedIn, signOut } = useInsforge();\n *\n * if (!isSignedIn) return <SignIn />;\n *\n * return (\n * <div>\n * <p>Welcome {user.email}</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport const useInsforge = useReactInsforge;\n\n// Re-export types\nexport type { InitialAuthState };\n"],"mappings":";AA4NQ;AA1NR;AAAA,EACE;AAAA,EAGA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAiClC,eAAe,kBAAkB,OAA8B;AAC7D,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,aAAa;AAAA,MACxC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK;AAAA,QAC9B,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB,QAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,cAAQ,MAAM,gDAAgD,SAAS;AAAA,IACzE;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,6DAA6D,GAAG;AAAA,EAChF;AACF;AAGA,eAAe,aAAa,OAA8B;AACxD,QAAM,kBAAkB,KAAK;AAC/B;AAGA,eAAe,cAAc,OAA8B;AACzD,QAAM,kBAAkB,KAAK;AAC/B;AAGA,eAAe,gBAA+B;AAC5C,MAAI;AACF,UAAM,MAAM,aAAa,EAAE,QAAQ,SAAS,CAAC;AAAA,EAC/C,QAAQ;AAAA,EAER;AACF;AAqHO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe,EAAE,MAAM,MAAM,QAAQ,KAAK;AAC5C,GAAiC;AAC/B,QAAM,gBAAuC;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,EACF;AAEA,SACE,oBAAC,iBACC,8BAAC,sBAAmB,SAAS,mBAC3B,8BAAC,wBAAsB,GAAG,eAAgB,UAAS,GACrD,GACF;AAEJ;AAgBO,MAAM,yBAAyB;AAuB/B,MAAM,cAAc;","names":[]}
package/dist/esm/index.js CHANGED
@@ -42,6 +42,8 @@ import {
42
42
  AuthResetPasswordVerificationStep
43
43
  } from "./client/components";
44
44
  import { useAuth, useUser, usePublicAuthConfig } from "./client/hooks";
45
+ import { getAuthFromCookies } from "./server/InsforgeProvider";
46
+ import { auth } from "./server/auth";
45
47
  export {
46
48
  AuthBranding,
47
49
  AuthContainer,
@@ -77,6 +79,8 @@ export {
77
79
  UserButton,
78
80
  VerifyEmail,
79
81
  VerifyEmailStatus,
82
+ auth,
83
+ getAuthFromCookies,
80
84
  useAuth,
81
85
  useInsforge,
82
86
  usePublicAuthConfig,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Provider - Uses conditional exports to provide correct version\n// In Server Components: exports from server/InsforgeProvider (async, uses next/headers)\n// In Client Components: exports from client/provider (use client)\nexport { InsforgeProvider } from '#components';\n\n// Browser Provider - The recommended way to use Insforge in Next.js\n// Use this directly in a client component for proper SDK client sharing\nexport { \n InsforgeBrowserProvider,\n ClientInsforgeProvider, // Deprecated alias\n type InsforgeBrowserProviderProps,\n type InitialAuthState,\n} from './client/provider';\n\n// Hooks (from client)\nexport { useInsforge } from './client/provider';\n\n/**\n * These need to be explicitly listed. Do not use an * here.\n * If you do, app router will break.\n *\n * Pattern learned from @clerk/nextjs\n */\n\n// Main UI Components\nexport {\n SignIn,\n SignUp,\n ForgotPassword,\n ResetPassword,\n VerifyEmail,\n UserButton,\n Protect,\n SignedIn,\n SignedOut,\n SignInButton,\n SignUpButton,\n} from './client/components';\n\n// Form Components\nexport {\n SignInForm,\n SignUpForm,\n ForgotPasswordForm,\n ResetPasswordForm,\n VerifyEmailStatus,\n} from './client/components';\n\n// Atom Components\nexport {\n AuthBranding,\n AuthContainer,\n AuthHeader,\n AuthErrorBanner,\n AuthFormField,\n AuthPasswordField,\n AuthPasswordStrengthIndicator,\n AuthSubmitButton,\n AuthLink,\n AuthDivider,\n AuthOAuthButton,\n AuthOAuthProviders,\n AuthVerificationCodeInput,\n AuthEmailVerificationStep,\n AuthResetPasswordVerificationStep,\n} from './client/components';\n\n// Component Types\nexport type {\n SignInProps,\n SignUpProps,\n ForgotPasswordProps,\n ResetPasswordProps,\n VerifyEmailProps,\n UserButtonProps,\n ProtectProps,\n ConditionalProps,\n SignInFormProps,\n SignUpFormProps,\n ForgotPasswordFormProps,\n ResetPasswordFormProps,\n VerifyEmailStatusProps,\n AuthContainerProps,\n AuthHeaderProps,\n AuthErrorBannerProps,\n AuthFormFieldProps,\n AuthPasswordFieldProps,\n AuthPasswordStrengthIndicatorProps,\n AuthSubmitButtonProps,\n AuthLinkProps,\n AuthDividerProps,\n AuthOAuthButtonProps,\n AuthOAuthProvidersProps,\n AuthVerificationCodeInputProps,\n} from './client/components';\n\n// Hooks\nexport { useAuth, useUser, usePublicAuthConfig } from './client/hooks';\n"],"mappings":"AAGA,SAAS,wBAAwB;AAIjC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAGP,SAAS,mBAAmB;AAU5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgCP,SAAS,SAAS,SAAS,2BAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Provider - Uses conditional exports to provide correct version\n// In Server Components: exports from server/InsforgeProvider (async, uses next/headers)\n// In Client Components: exports from client/provider (use client)\nexport { InsforgeProvider } from '#components';\n\n// Browser Provider - The recommended way to use Insforge in Next.js\n// Use this directly in a client component for proper SDK client sharing\nexport { \n InsforgeBrowserProvider,\n ClientInsforgeProvider, // Deprecated alias\n type InsforgeBrowserProviderProps,\n type InitialAuthState,\n} from './client/provider';\n\n// Hooks (from client)\nexport { useInsforge } from './client/provider';\n\n/**\n * These need to be explicitly listed. Do not use an * here.\n * If you do, app router will break.\n *\n * Pattern learned from @clerk/nextjs\n */\n\n// Main UI Components\nexport {\n SignIn,\n SignUp,\n ForgotPassword,\n ResetPassword,\n VerifyEmail,\n UserButton,\n Protect,\n SignedIn,\n SignedOut,\n SignInButton,\n SignUpButton,\n} from './client/components';\n\n// Form Components\nexport {\n SignInForm,\n SignUpForm,\n ForgotPasswordForm,\n ResetPasswordForm,\n VerifyEmailStatus,\n} from './client/components';\n\n// Atom Components\nexport {\n AuthBranding,\n AuthContainer,\n AuthHeader,\n AuthErrorBanner,\n AuthFormField,\n AuthPasswordField,\n AuthPasswordStrengthIndicator,\n AuthSubmitButton,\n AuthLink,\n AuthDivider,\n AuthOAuthButton,\n AuthOAuthProviders,\n AuthVerificationCodeInput,\n AuthEmailVerificationStep,\n AuthResetPasswordVerificationStep,\n} from './client/components';\n\n// Component Types\nexport type {\n SignInProps,\n SignUpProps,\n ForgotPasswordProps,\n ResetPasswordProps,\n VerifyEmailProps,\n UserButtonProps,\n ProtectProps,\n ConditionalProps,\n SignInFormProps,\n SignUpFormProps,\n ForgotPasswordFormProps,\n ResetPasswordFormProps,\n VerifyEmailStatusProps,\n AuthContainerProps,\n AuthHeaderProps,\n AuthErrorBannerProps,\n AuthFormFieldProps,\n AuthPasswordFieldProps,\n AuthPasswordStrengthIndicatorProps,\n AuthSubmitButtonProps,\n AuthLinkProps,\n AuthDividerProps,\n AuthOAuthButtonProps,\n AuthOAuthProvidersProps,\n AuthVerificationCodeInputProps,\n} from './client/components';\n\n// Hooks\nexport { useAuth, useUser, usePublicAuthConfig } from './client/hooks';\n\n// Server utilities (use in Server Components only)\nexport { getAuthFromCookies } from './server/InsforgeProvider';\nexport { auth, type InsforgeAuth } from './server/auth';\n"],"mappings":"AAGA,SAAS,wBAAwB;AAIjC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAGP,SAAS,mBAAmB;AAU5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgCP,SAAS,SAAS,SAAS,2BAA2B;AAGtD,SAAS,0BAA0B;AACnC,SAAS,YAA+B;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/InsforgeProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { InsforgeBrowserProvider } from '../client/provider';\nimport type { InsforgeProviderProps, InitialAuthState } from '@insforge/react';\nimport { cookies } from 'next/headers';\nimport { COOKIE_NAMES, parseUserCookie } from '../lib/cookies';\nimport type { InsForgeClient } from '@insforge/sdk';\n\nexport interface InsforgeProviderServerProps extends Omit<InsforgeProviderProps, 'initialState'> {\n children: ReactNode;\n /**\n * The InsForge SDK client instance.\n * \n * ⚠️ **Warning:** In Next.js, SDK client instances (class objects) cannot be\n * passed from Server Components to Client Components. You should use\n * `InsforgeBrowserProvider` directly in a client component instead.\n */\n client: InsForgeClient;\n /**\n * Opt into dynamic rendering to read auth state from cookies during SSR.\n *\n * - When true: Reads cookies on server, prevents content flashing, opts into dynamic rendering\n * - When false: Static rendering, may see brief content flash during hydration\n *\n * @default true\n */\n dynamic?: boolean;\n}\n\n/**\n * Get initial auth state from cookies (server-side)\n *\n * This helper reads the authentication state from cookies set by the SDK.\n * Use this in Server Components to get the initial auth state and pass it\n * to `InsforgeBrowserProvider` via the `initialState` prop.\n *\n * This prevents hydration mismatches by ensuring SSR and client render have the same state.\n *\n * @example\n * ```tsx\n * // app/layout.tsx (Server Component)\n * import { getAuthFromCookies } from '@insforge/nextjs/server';\n * import { Providers } from './providers';\n *\n * export default async function RootLayout({ children }) {\n * const initialState = await getAuthFromCookies();\n *\n * return (\n * <html>\n * <body>\n * <Providers initialState={initialState}>\n * {children}\n * </Providers>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * @returns Initial auth state with user and userId, or null values if not authenticated\n */\nexport async function getAuthFromCookies(): Promise<InitialAuthState> {\n try {\n const cookieStore = await cookies();\n\n // Read session token from cookie (set by middleware or /api/auth route)\n const token = cookieStore.get(COOKIE_NAMES.SESSION)?.value || null;\n\n if (!token) {\n // Not authenticated - return null to indicate signed out\n return {\n user: null,\n userId: null,\n };\n }\n\n // Read user identity from cookie (set by middleware or /api/auth route)\n const userCookie = cookieStore.get(COOKIE_NAMES.USER)?.value;\n\n try {\n const user = parseUserCookie(userCookie);\n\n // Return basic user info from cookie\n // This is lightweight data for SSR hydration only\n // Full profile will be loaded by SDK's getCurrentUser() after hydration\n return {\n user,\n userId: user?.id || null,\n };\n } catch {\n // Invalid user data in cookie\n return {\n user: null,\n userId: null,\n };\n }\n } catch (error) {\n // Error reading cookies (might be in middleware or edge runtime)\n console.error('[Insforge] Error reading cookies:', error);\n return {\n user: null,\n userId: null,\n };\n }\n}\n\n/**\n * @deprecated **This component is deprecated.** Use `InsforgeBrowserProvider` instead.\n *\n * This Server Component wrapper doesn't work correctly because SDK client instances\n * (class objects) cannot be serialized and passed from Server to Client Components.\n *\n * ---\n *\n * ## Migration Guide\n *\n * ### Before (deprecated):\n * ```tsx\n * // app/layout.tsx\n * import { InsforgeProvider } from '@insforge/nextjs';\n * import { insforge } from '@/lib/insforge';\n *\n * export default function RootLayout({ children }) {\n * return (\n * <InsforgeProvider client={insforge}> // ❌ This fails!\n * {children}\n * </InsforgeProvider>\n * );\n * }\n * ```\n *\n * ### After (recommended):\n *\n * **Step 1:** Create a client-side Providers component:\n * ```tsx\n * // app/providers.tsx\n * 'use client';\n * import { InsforgeBrowserProvider, type InitialAuthState } from '@insforge/nextjs';\n * import { insforge } from '@/lib/insforge';\n *\n * export function Providers({\n * children,\n * initialState,\n * }: {\n * children: React.ReactNode;\n * initialState?: InitialAuthState;\n * }) {\n * return (\n * <InsforgeBrowserProvider client={insforge} initialState={initialState}>\n * {children}\n * </InsforgeBrowserProvider>\n * );\n * }\n * ```\n *\n * **Step 2:** Use it in your layout:\n * ```tsx\n * // app/layout.tsx\n * import { getAuthFromCookies } from '@insforge/nextjs/server';\n * import { Providers } from './providers';\n *\n * export default async function RootLayout({ children }) {\n * const initialState = await getAuthFromCookies();\n *\n * return (\n * <html>\n * <body>\n * <Providers initialState={initialState}>\n * {children}\n * </Providers>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * ---\n *\n * @see InsforgeBrowserProvider - The recommended client-side provider\n * @see getAuthFromCookies - Helper to get initial auth state for SSR\n */\nexport async function InsforgeProvider(props: InsforgeProviderServerProps) {\n const { children, dynamic = true, client, ...restProps } = props;\n\n // Only read cookies if dynamic=true (opts into dynamic rendering)\n // When dynamic=false, Next.js can statically generate the page\n const initialAuth = dynamic ? await getAuthFromCookies() : { user: null, userId: null };\n\n // Pass initialState to Client Provider\n // Note: This will fail at runtime because `client` is a class instance\n return (\n <InsforgeBrowserProvider client={client} initialState={initialAuth} {...restProps}>\n {children}\n </InsforgeBrowserProvider>\n );\n}\n"],"mappings":"AA8LI;AA7LJ,SAAS,+BAA+B;AAExC,SAAS,eAAe;AACxB,SAAS,cAAc,uBAAuB;AAwD9C,eAAsB,qBAAgD;AACpE,MAAI;AACF,UAAM,cAAc,MAAM,QAAQ;AAGlC,UAAM,QAAQ,YAAY,IAAI,aAAa,OAAO,GAAG,SAAS;AAE9D,QAAI,CAAC,OAAO;AAEV,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF;AAGA,UAAM,aAAa,YAAY,IAAI,aAAa,IAAI,GAAG;AAEvD,QAAI;AACF,YAAM,OAAO,gBAAgB,UAAU;AAKvC,aAAO;AAAA,QACL;AAAA,QACA,QAAQ,MAAM,MAAM;AAAA,MACtB;AAAA,IACF,QAAQ;AAEN,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,MAAM,qCAAqC,KAAK;AACxD,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF;AACF;AA6EA,eAAsB,iBAAiB,OAAoC;AACzE,QAAM,EAAE,UAAU,UAAU,MAAM,QAAQ,GAAG,UAAU,IAAI;AAI3D,QAAM,cAAc,UAAU,MAAM,mBAAmB,IAAI,EAAE,MAAM,MAAM,QAAQ,KAAK;AAItF,SACE,oBAAC,2BAAwB,QAAgB,cAAc,aAAc,GAAG,WACrE,UACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/InsforgeProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { InsforgeBrowserProvider } from '../client/provider';\nimport type { InsforgeProviderProps, InitialAuthState } from '@insforge/react';\nimport { cookies } from 'next/headers';\nimport { COOKIE_NAMES, parseUserCookie } from '../lib/cookies';\nimport type { InsForgeClient } from '@insforge/sdk';\n\nexport interface InsforgeProviderServerProps extends Omit<InsforgeProviderProps, 'initialState'> {\n children: ReactNode;\n /**\n * The InsForge SDK client instance.\n * \n * ⚠️ **Warning:** In Next.js, SDK client instances (class objects) cannot be\n * passed from Server Components to Client Components. You should use\n * `InsforgeBrowserProvider` directly in a client component instead.\n */\n client: InsForgeClient;\n /**\n * Opt into dynamic rendering to read auth state from cookies during SSR.\n *\n * - When true: Reads cookies on server, prevents content flashing, opts into dynamic rendering\n * - When false: Static rendering, may see brief content flash during hydration\n *\n * @default true\n */\n dynamic?: boolean;\n}\n\n/**\n * Get initial auth state from cookies (server-side)\n *\n * This helper reads the authentication state from cookies set by the SDK.\n * Use this in Server Components to get the initial auth state and pass it\n * to `InsforgeBrowserProvider` via the `initialState` prop.\n *\n * This prevents hydration mismatches by ensuring SSR and client render have the same state.\n *\n * @example\n * ```tsx\n * // app/layout.tsx (Server Component)\n * import { getAuthFromCookies } from '@insforge/nextjs';\n * import { Providers } from './providers';\n *\n * export default async function RootLayout({ children }) {\n * const initialState = await getAuthFromCookies();\n *\n * return (\n * <html>\n * <body>\n * <Providers initialState={initialState}>\n * {children}\n * </Providers>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * @returns Initial auth state with user and userId, or null values if not authenticated\n */\nexport async function getAuthFromCookies(): Promise<InitialAuthState> {\n try {\n const cookieStore = await cookies();\n\n // Read session token from cookie (set by middleware or /api/auth route)\n const token = cookieStore.get(COOKIE_NAMES.SESSION)?.value || null;\n\n if (!token) {\n // Not authenticated - return null to indicate signed out\n return {\n user: null,\n userId: null,\n };\n }\n\n // Read user identity from cookie (set by middleware or /api/auth route)\n const userCookie = cookieStore.get(COOKIE_NAMES.USER)?.value;\n\n try {\n const user = parseUserCookie(userCookie);\n\n // Return basic user info from cookie\n // This is lightweight data for SSR hydration only\n // Full profile will be loaded by SDK's getCurrentUser() after hydration\n return {\n user,\n userId: user?.id || null,\n };\n } catch {\n // Invalid user data in cookie\n return {\n user: null,\n userId: null,\n };\n }\n } catch (error) {\n // Error reading cookies (might be in middleware or edge runtime)\n console.error('[Insforge] Error reading cookies:', error);\n return {\n user: null,\n userId: null,\n };\n }\n}\n\n/**\n * @deprecated **This component is deprecated.** Use `InsforgeBrowserProvider` instead.\n *\n * This Server Component wrapper doesn't work correctly because SDK client instances\n * (class objects) cannot be serialized and passed from Server to Client Components.\n *\n * ---\n *\n * ## Migration Guide\n *\n * ### Before (deprecated):\n * ```tsx\n * // app/layout.tsx\n * import { InsforgeProvider } from '@insforge/nextjs';\n * import { insforge } from '@/lib/insforge';\n *\n * export default function RootLayout({ children }) {\n * return (\n * <InsforgeProvider client={insforge}> // ❌ This fails!\n * {children}\n * </InsforgeProvider>\n * );\n * }\n * ```\n *\n * ### After (recommended):\n *\n * **Step 1:** Create a client-side Providers component:\n * ```tsx\n * // app/providers.tsx\n * 'use client';\n * import { InsforgeBrowserProvider, type InitialAuthState } from '@insforge/nextjs';\n * import { insforge } from '@/lib/insforge';\n *\n * export function Providers({\n * children,\n * initialState,\n * }: {\n * children: React.ReactNode;\n * initialState?: InitialAuthState;\n * }) {\n * return (\n * <InsforgeBrowserProvider client={insforge} initialState={initialState}>\n * {children}\n * </InsforgeBrowserProvider>\n * );\n * }\n * ```\n *\n * **Step 2:** Use it in your layout:\n * ```tsx\n * // app/layout.tsx\n * import { getAuthFromCookies } from '@insforge/nextjs';\n * import { Providers } from './providers';\n *\n * export default async function RootLayout({ children }) {\n * const initialState = await getAuthFromCookies();\n *\n * return (\n * <html>\n * <body>\n * <Providers initialState={initialState}>\n * {children}\n * </Providers>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * ---\n *\n * @see InsforgeBrowserProvider - The recommended client-side provider\n * @see getAuthFromCookies - Helper to get initial auth state for SSR\n */\nexport async function InsforgeProvider(props: InsforgeProviderServerProps) {\n const { children, dynamic = true, client, ...restProps } = props;\n\n // Only read cookies if dynamic=true (opts into dynamic rendering)\n // When dynamic=false, Next.js can statically generate the page\n const initialAuth = dynamic ? await getAuthFromCookies() : { user: null, userId: null };\n\n // Pass initialState to Client Provider\n // Note: This will fail at runtime because `client` is a class instance\n return (\n <InsforgeBrowserProvider client={client} initialState={initialAuth} {...restProps}>\n {children}\n </InsforgeBrowserProvider>\n );\n}\n"],"mappings":"AA8LI;AA7LJ,SAAS,+BAA+B;AAExC,SAAS,eAAe;AACxB,SAAS,cAAc,uBAAuB;AAwD9C,eAAsB,qBAAgD;AACpE,MAAI;AACF,UAAM,cAAc,MAAM,QAAQ;AAGlC,UAAM,QAAQ,YAAY,IAAI,aAAa,OAAO,GAAG,SAAS;AAE9D,QAAI,CAAC,OAAO;AAEV,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF;AAGA,UAAM,aAAa,YAAY,IAAI,aAAa,IAAI,GAAG;AAEvD,QAAI;AACF,YAAM,OAAO,gBAAgB,UAAU;AAKvC,aAAO;AAAA,QACL;AAAA,QACA,QAAQ,MAAM,MAAM;AAAA,MACtB;AAAA,IACF,QAAQ;AAEN,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,MAAM,qCAAqC,KAAK;AACxD,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF;AACF;AA6EA,eAAsB,iBAAiB,OAAoC;AACzE,QAAM,EAAE,UAAU,UAAU,MAAM,QAAQ,GAAG,UAAU,IAAI;AAI3D,QAAM,cAAc,UAAU,MAAM,mBAAmB,IAAI,EAAE,MAAM,MAAM,QAAQ,KAAK;AAItF,SACE,oBAAC,2BAAwB,QAAgB,cAAc,aAAc,GAAG,WACrE,UACH;AAEJ;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- export { InsforgeProvider } from './server/InsforgeProvider.js';
1
+ export { InsforgeProvider, getAuthFromCookies } from './server/InsforgeProvider.js';
2
2
  export { ClientInsforgeProvider, InsforgeBrowserProvider, InsforgeBrowserProviderProps, useInsforge } from './client/provider.js';
3
3
  export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps, ConditionalProps, ForgotPassword, ForgotPasswordForm, ForgotPasswordFormProps, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordForm, ResetPasswordFormProps, ResetPasswordProps, SignIn, SignInButton, SignInForm, SignInFormProps, SignInProps, SignUp, SignUpButton, SignUpForm, SignUpFormProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps, VerifyEmailStatus, VerifyEmailStatusProps } from '@insforge/react/components';
4
4
  export { useAuth, usePublicAuthConfig, useUser } from './client/hooks.js';
5
+ export { InsforgeAuth, auth } from './server/auth.js';
5
6
  export { InitialAuthState } from '@insforge/react';
6
7
  import 'react/jsx-runtime';
7
8
  import 'react';
8
9
  import '@insforge/sdk';
9
10
  import '@insforge/shared-schemas';
11
+ import '@insforge/shared';
@@ -35,7 +35,7 @@ interface InsforgeProviderServerProps extends Omit<InsforgeProviderProps, 'initi
35
35
  * @example
36
36
  * ```tsx
37
37
  * // app/layout.tsx (Server Component)
38
- * import { getAuthFromCookies } from '@insforge/nextjs/server';
38
+ * import { getAuthFromCookies } from '@insforge/nextjs';
39
39
  * import { Providers } from './providers';
40
40
  *
41
41
  * export default async function RootLayout({ children }) {
@@ -108,7 +108,7 @@ declare function getAuthFromCookies(): Promise<InitialAuthState>;
108
108
  * **Step 2:** Use it in your layout:
109
109
  * ```tsx
110
110
  * // app/layout.tsx
111
- * import { getAuthFromCookies } from '@insforge/nextjs/server';
111
+ * import { getAuthFromCookies } from '@insforge/nextjs';
112
112
  * import { Providers } from './providers';
113
113
  *
114
114
  * export default async function RootLayout({ children }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insforge/nextjs",
3
- "version": "1.0.5-dev.7",
3
+ "version": "1.0.5-dev.9",
4
4
  "description": "Pre-built authentication UI components for Next.js with Insforge backend - zero configuration required",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",