Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Hydration failed because the initial UI does not match what was rendered on the server. #982

Closed
Tarbez opened this issue Jun 7, 2024 · 2 comments

Comments

@Tarbez
Copy link

Tarbez commented Jun 7, 2024

Describe the bug
Using the default components designed by the library, I can't seem to figure a way to fix this unless I do overwrite most of the work and the files, and since am using a the new version of nextjs somehow I'm facing this issue >

Error: Hydration failed because the initial UI does not match what was rendered on the server.

To Reproduce
Steps to reproduce the behavior:

  1. Simply use the library in nextjs 14+
  2. the issue for the hydration should appear

Expected behavior
It should not be a button that is wrapping the next component cause then you would have 2 buttons nested.

Screenshots
Screenshot 2024-06-08 at 00 55 31

@crypblizz8
Copy link

crypblizz8 commented Jun 10, 2024

Saw a similar issue when I tried this and read somewhere dynamic in Next is the best way to resolve this.

i.e.

import dynamic from "next/dynamic";
...

const WalletMultiButtonDynamic = dynamic(
  async () =>
    (await import("@solana/wallet-adapter-react-ui")).WalletMultiButton,
  { ssr: false }
);

...

return (
    <main>
      <div>
        <WalletMultiButtonDynamic>
          ....
        </WalletMultiButtonDynamic>
      </div>
    </main>

Hope that helps.

@jordaaash
Copy link
Collaborator

dynamic in Next is the best way to resolve this

Yeah, that's right. The state on the client will always be different than the server because the server can't know about the wallets injected into the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants