diff --git a/.next/app-build-manifest.json b/.next/app-build-manifest.json index 36b6665..ef10b1f 100644 --- a/.next/app-build-manifest.json +++ b/.next/app-build-manifest.json @@ -1,16 +1,16 @@ { "pages": { - "/page": [ - "static/chunks/webpack.js", - "static/chunks/main-app.js", - "static/chunks/app/page.js" - ], "/layout": [ "static/chunks/webpack.js", "static/chunks/main-app.js", "static/css/app/layout.css", "static/chunks/app/layout.js" ], + "/page": [ + "static/chunks/webpack.js", + "static/chunks/main-app.js", + "static/chunks/app/page.js" + ], "/not-found": [ "static/chunks/webpack.js", "static/chunks/main-app.js", diff --git a/.next/cache/webpack/client-development/1.pack.gz b/.next/cache/webpack/client-development/1.pack.gz index 4ecf7eb..4f009cc 100644 Binary files a/.next/cache/webpack/client-development/1.pack.gz and b/.next/cache/webpack/client-development/1.pack.gz differ diff --git a/.next/cache/webpack/client-development/index.pack.gz b/.next/cache/webpack/client-development/index.pack.gz index 3bf84fa..76094a5 100644 Binary files a/.next/cache/webpack/client-development/index.pack.gz and b/.next/cache/webpack/client-development/index.pack.gz differ diff --git a/.next/cache/webpack/client-development/index.pack.gz.old b/.next/cache/webpack/client-development/index.pack.gz.old index 6546dc5..eb45cf0 100644 Binary files a/.next/cache/webpack/client-development/index.pack.gz.old and b/.next/cache/webpack/client-development/index.pack.gz.old differ diff --git a/.next/cache/webpack/server-development/0.pack.gz b/.next/cache/webpack/server-development/0.pack.gz index bbc3952..0acbdf6 100644 Binary files a/.next/cache/webpack/server-development/0.pack.gz and b/.next/cache/webpack/server-development/0.pack.gz differ diff --git a/.next/cache/webpack/server-development/index.pack.gz b/.next/cache/webpack/server-development/index.pack.gz index 13595ed..6f1ce4b 100644 Binary files a/.next/cache/webpack/server-development/index.pack.gz and b/.next/cache/webpack/server-development/index.pack.gz differ diff --git a/app/components/ClientOnly.tsx b/app/components/ClientOnly.tsx new file mode 100644 index 0000000..6bf2620 --- /dev/null +++ b/app/components/ClientOnly.tsx @@ -0,0 +1,17 @@ +'use client'; + +import { useEffect, useState } from 'react'; + +export default function ClientOnly({ children }: { children: React.ReactNode }) { + const [hasMounted, setHasMounted] = useState(false); + + useEffect(() => { + setHasMounted(true); + }, []); + + if (!hasMounted) { + return null; + } + + return <>{children}; +} \ No newline at end of file diff --git a/app/components/MainApp.tsx b/app/components/MainApp.tsx index 94453ae..171457f 100644 --- a/app/components/MainApp.tsx +++ b/app/components/MainApp.tsx @@ -9,6 +9,7 @@ import { auth, getProfile, getShopItems, purchaseItem, transferBalance } from '. import { IUser } from '../../backend/models/User'; import { IShopItem } from '../../backend/models/ShopItem'; import { isDemoMode, getDemoWebApp } from '../utils/demo'; +import WebApp from '@twa-dev/sdk'; type SafeUser = Omit; @@ -25,9 +26,10 @@ export default function MainApp() { let webApp; if (isDemoMode()) { webApp = getDemoWebApp(); - } else { - const WebApp = (await import('@twa-dev/sdk')).default; + } else if (typeof window !== 'undefined') { webApp = WebApp; + } else { + throw new Error('Приложение должно быть открыто в браузере'); } // Авторизация пользователя diff --git a/app/page.tsx b/app/page.tsx index 2245401..8d1240f 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,5 +1,14 @@ -import MainApp from './components/MainApp'; +import dynamic from 'next/dynamic'; +import ClientOnly from './components/ClientOnly'; + +const MainApp = dynamic(() => import('./components/MainApp'), { + ssr: false, +}); export default function Home() { - return ; + return ( + + + + ); } \ No newline at end of file