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 143 forks source link

[Bug]: Hooks SSR error for client components #440

Closed thecoorum closed 1 month ago

thecoorum commented 1 month ago

Telegram Application

Telegram for macOS

Describe the Bug

When using @telegram-apps/sdk-react in the client components it always logs the following error to the console

Error: Using hooks on the server side, you must explicitly specify ssr = true option

Is that expected behavior?

To Reproduce

Steps to reproduce the behavior:

  1. Using Next.js starter create a component/page/provider with "use client" directive at the top of the file
  2. See an error

Expected Behavior

I don't really know if that's an expected behavior or not

heyqbnk commented 1 month ago

I don't know how the next client components work. If you see this message, it means, the hook was called on the server side (where window is missing)

json-jcc commented 1 month ago

i also found this bug, i used these hooks with ssr=false in a next.js client component, reports this 'Using hooks on the server side, you must explicitly specify ssr = true option'

heyqbnk commented 1 month ago

Next.js client components may be rendered on the server side: https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered