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

@electric-sql/react with next.js hydration mismatch #2290

Open
tonyxiao opened this issue Feb 4, 2025 · 1 comment
Open

@electric-sql/react with next.js hydration mismatch #2290

tonyxiao opened this issue Feb 4, 2025 · 1 comment

Comments

@tonyxiao
Copy link

tonyxiao commented Feb 4, 2025

Initial load works great. Subsequent load I get next.js hydration mismatch issue.
This is my component code.

'use client'

import {useShape} from '@electric-sql/react'

export default function TransactionList() {
  const {data} = useShape({
    url: `http://localhost:3334/v1/shape`,
    params: {
      table: `transaction`,
      columns: ['connection_id', `id`, `amount`, `currency`, 'memo'],
    },
  })

  return <pre>{JSON.stringify(data, null, 2)}</pre>
}

And this is the error I get.

Uncaught Error: Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:
Image
@tonyxiao tonyxiao changed the title electric sql next.js hydration mismatch issue @electric-sql/react with next.js hydration mismatch Feb 4, 2025
@KyleAMathews
Copy link
Contributor

Hmm we do have a nextjs example which doesn't have this issue — https://github.com/electric-sql/electric/tree/main/examples/nextjs Perhaps we did something to disable SSR?

I'm not super familiar with next.js so not entirely sure what's going on.

BTW, we do have WIP support for SSR — #2232 which presumably fix the issue you're seeing.

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

2 participants