sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[UI-REACT]: TonConnectUIProvider cause hydration warnings in Next.js dev server

Open baadev opened this issue 2 years ago • 2 comments

Describe the bug

Adding TonConnectUIProvider in Next.js app within dev build causes Warning: Extra attributes from the server: ontouchstart,style.

Expected behavior

Adding TonConnectUIProvider should not cause any hydration warnings

Current behavior

Adding TonConnectUIProvider causes hydration warnings image

Steps to Reproduce

  1. add TonConnectUIProvider to your Next.js project within body tag as separate client component
  2. run dev server: npm run dev
  3. check the console of your browser

Environment

MacOS 15.0 (24A335)

Safari Version 18.0 (20619.1.26.31.6) or Chrome Version 129.0.6668.59 (Official Build) (arm64)

"@tonconnect/ui-react": "^2.0.9", "next": "14.2.15", "react": "^18", "react-dom": "^18"

Additional context

This issue is not visible for production build.

baadev avatar Oct 17 '24 07:10 baadev

temporal solution is to make sure that the provider is on "use client" and to add suppressHydrationWarning to the html tag <html lang="en" suppressHydrationWarning>

srpiroliro avatar Jan 16 '25 18:01 srpiroliro

temporal solution is to make sure that the provider is on "use client" and to add suppressHydrationWarning to the html tag <html lang="en" suppressHydrationWarning>

That’s what I did, thank you. I was hoping for a better solution or fix than simply suppressing the warning, but this approach does work anyway.

baadev avatar Jan 16 '25 18:01 baadev