Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.
https://docs.telegram-mini-apps.com/
MIT License
564 stars 142 forks source link

[Bug]: nextJS SSR useInitData is broken #461

Open mikhaillav opened 2 weeks ago

mikhaillav commented 2 weeks ago

Telegram Application

Other

Describe the Bug

I tried to run useInitData(true) in the nextjs server component. But got an error:

TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_1__.createContext) is not a function

Result is the same in chrome or telegram desktop mini-app. Im using latest versions of nextjs(14.2.7), react(18.3.1) and sdk(1.1.3).

To Reproduce

Steps to reproduce the behavior:

  1. Run code below
    
    // page.tsx
    import { useInitData } from "@telegram-apps/sdk-react";

export default async function Test() { const initData = useInitData(true);

console.log(initData);

return <p>test</p>;

}



### Expected Behavior

Expected to see `InitData | undefined` in console logs and not an error
mikhaillav commented 2 weeks ago

I also noticed same error occurs on basically every use... method (useInitData, useLaunchParams, useMiniAppRaw, useViewport...).

heyqbnk commented 2 weeks ago

Seems like you are doing something wrong with Next.js: https://github.com/vercel/next.js/discussions/49074