diff --git a/package.json b/package.json
index 7476681..60cf744 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@neynar/create-farcaster-mini-app",
- "version": "1.7.8",
+ "version": "1.7.9",
"type": "module",
"private": false,
"access": "public",
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 6b3ad05..c42d41a 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -22,8 +22,9 @@ export default async function RootLayout({
let session = null;
if (shouldUseSession) {
try {
- const { getSession } = await import('~/auth');
- session = await getSession();
+ // @ts-ignore - auth module may not exist in all template variants
+ const authModule = eval('require("~/auth")');
+ session = await authModule.getSession();
} catch (error) {
console.warn('Failed to get session:', error);
}
diff --git a/src/app/providers.tsx b/src/app/providers.tsx
index 4e1453f..d9c19fa 100644
--- a/src/app/providers.tsx
+++ b/src/app/providers.tsx
@@ -1,12 +1,9 @@
'use client';
import dynamic from 'next/dynamic';
-import type { Session } from 'next-auth';
-import { SessionProvider } from 'next-auth/react';
import { MiniAppProvider } from '@neynar/react';
import { SafeFarcasterSolanaProvider } from '~/components/providers/SafeFarcasterSolanaProvider';
import { ANALYTICS_ENABLED } from '~/lib/constants';
-import { AuthKitProvider } from '@farcaster/auth-kit';
const WagmiProvider = dynamic(
() => import('~/components/providers/WagmiProvider'),
@@ -15,12 +12,14 @@ const WagmiProvider = dynamic(
}
);
+
+
export function Providers({
session,
children,
shouldUseSession = false,
}: {
- session: Session | null;
+ session: any | null;
children: React.ReactNode;
shouldUseSession?: boolean;
}) {
@@ -29,19 +28,41 @@ export function Providers({
// Only wrap with SessionProvider if next auth is used
if (shouldUseSession) {
+ // Dynamic import for auth components - will work if modules exist, fallback if not
+ const AuthWrapper = dynamic(
+ () => {
+ return Promise.resolve().then(() => {
+ // Use eval to avoid build-time module resolution
+ try {
+ // @ts-ignore - These modules may not exist in all template variants
+ const nextAuth = eval('require("next-auth/react")');
+ const authKit = eval('require("@farcaster/auth-kit")');
+
+ return ({ children }: { children: React.ReactNode }) => (
+
+ {children}
+
+ );
+ } catch (error) {
+ // Fallback component when auth modules aren't available
+ return ({ children }: { children: React.ReactNode }) => <>{children}>;
+ }
+ });
+ },
+ { ssr: false }
+ );
+
return (
-
-
-
-
- {children}
-
-
-
-
+
+
+
+ {children}
+
+
+
);
}
@@ -53,7 +74,7 @@ export function Providers({
backButtonEnabled={true}
>
- {children}
+ {children}
diff --git a/src/components/ui/tabs/ActionsTab.tsx b/src/components/ui/tabs/ActionsTab.tsx
index 18e6e22..bc7880d 100644
--- a/src/components/ui/tabs/ActionsTab.tsx
+++ b/src/components/ui/tabs/ActionsTab.tsx
@@ -1,5 +1,6 @@
'use client';
+import dynamic from 'next/dynamic';
import { useCallback, useState, type ComponentType } from 'react';
import { useMiniApp } from '@neynar/react';
import { ShareButton } from '../Share';
@@ -9,14 +10,21 @@ import { type Haptics } from '@farcaster/miniapp-sdk';
import { APP_URL } from '~/lib/constants';
// Optional import for NeynarAuthButton - may not exist in all templates
-let NeynarAuthButton: ComponentType | null = null;
-try {
- const module = require('../NeynarAuthButton/index');
- NeynarAuthButton = module.NeynarAuthButton;
-} catch (error) {
- // Component doesn't exist, that's okay
- console.log('NeynarAuthButton not available in this template');
-}
+const NeynarAuthButton = dynamic(
+ () => {
+ return Promise.resolve().then(() => {
+ try {
+ // @ts-ignore - NeynarAuthButton may not exist in all template variants
+ const module = eval('require("../NeynarAuthButton/index")');
+ return module.default || module.NeynarAuthButton;
+ } catch (error) {
+ // Return null component when module doesn't exist
+ return () => null;
+ }
+ });
+ },
+ { ssr: false }
+);
/**