Skip to content

Getting hydration issue when using useState in different components #18627

@schneider-carlo

Description

@schneider-carlo

Environment

  • Operating System: Darwin
  • Node Version: v18.13.0
  • Nuxt Version: 3.1.1
  • Nitro Version: 2.1.1
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. git clone git@github.com:schneider-carlo/nuxt-3-use-state.git
  2. cd nuxt-3-use-state
  3. yarn install
  4. yarn dev
  5. open this url: http://localhost:3000?hello=world

Describe the bug

I want to read the current query information in the dynamic [...slug].vue page and store it to the useQueryState.ts composable. After that I want to output this stored information in the header.vue component. When I am doing this, I am getting a hydration issue (getting cumulative layout shift and console warning). Curiously when I output this information in the [...slug].vue page it works fine.

I really would like to know if this a bug or I am doing something wrong, because I faced this issue multiple times and don't know how to fix this.

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions