NuxtImage Hydration mismatch
Hi everyone 🙂
am facing a Hydration mismatch issue with Nuxt image and I need some help 🙂
the project am working on is a Nuxt 3.17, NuxtImg 1.10 with ipx provider.
when i run the project in dev mode i get Hydration mismatch warning that the srcset is different between the server and the client.
message:
- rendered on server: srcset="/_ipx/f_webp&s_248x177/https://www.domain.com/files/image.jpg, /_ipx/f_webp&s_496x354/https://www.domain.com/files/image.jpg 2x"
- expected on client: srcset="/_ipx/f_webp&s_248x177/https://www.domain.com/files/image.jpg 1x, /_ipx/f_webp&s_496x354/https://www.domain.com/files/image.jpg 2x"
as you can notice in the server the first image value doesn't have the "1x"!
in the nuxt.config I have set "densities: [1,2]"
and in the template I have set the Nuxt image like this:
<nuxt-img densities="x1 x2" format="webp" :src="image" :alt="imageAlt" width="120" height="75" loading="lazy"/>
any suggestions why this happening and how I could fix it ?
thanks in advance Pachanca 🙂
8 Replies
Hi @Pachanca. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The hydration mismatch you’re seeing—where the server-rendered
This is a known quirk with how
srcset
omits the 1x
descriptor but the client includes it—is a known issue that can occur with Nuxt Image and the IPX provider. Specifically, the server outputs:
while the client expects:
This difference is due to the fact that, according to the HTML spec, the 1x
descriptor is optional and often omitted by image processing libraries. However, Vue’s hydration expects the markup to match exactly between server and client, so this difference triggers a warning.
What you can do:
- This is a cosmetic mismatch and does not affect image loading or functionality. The browser treats both forms as equivalent.
- If you want to suppress the warning, you may need to wait for a fix in the Nuxt Image module or IPX provider that ensures consistent srcset
output between server and client.
- As a workaround, you could try updating to the latest version of Nuxt Image (v2.0.0-alpha.1 or later), as some related issues have been resolved in newer releases, especially around IPX and hydration mismatches. Users have reported that upgrading helped resolve similar issues Nuxt Image IPX provider issue.
Summary:This is a known quirk with how
srcset
is generated. The difference in the presence of 1x
is not functionally significant, but it does cause hydration warnings. Upgrading Nuxt Image may help, but if the warning persists, it is safe to ignore unless you see actual rendering issues.
If you need strict hydration matching, you may want to follow or open an issue on the Nuxt Image repository for a more permanent fix.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@434825695496241153> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai is there away to stop this warning from appearing?
Let me check the knowledge base for you again. One moment! :books:
----------------------
I'm sorry, but the knowledge sources do not explicitly mention a built-in way to suppress or stop hydration mismatch warnings specifically for Nuxt Image or the IPX provider. The documentation and community discussions explain why hydration mismatches occur (such as differences in server/client rendering of
srcset
), but they do not provide a configuration option or official workaround to hide these warnings in the console.
The only related information found is that hydration mismatch warnings are triggered when the HTML generated on the server does not exactly match the client, and that these must be resolved by ensuring consistent rendering logic between server and client. There is no mention of a Nuxt config or Nuxt Image setting to suppress these warnings directly Warnings that I don't understand.
If you are experiencing these warnings due to a known issue in Nuxt Image, the best course of action is to follow updates on the module or consider upgrading if a fix is released. Otherwise, there is no documented way to hide these warnings in the current knowledge sources.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@434825695496241153> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai is there an issue for this in github?
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the knowledge sources provided, there is no specific GitHub issue directly addressing the exact
srcset
hydration mismatch with the missing 1x
descriptor in Nuxt Image or the IPX provider. However, there are related discussions about hydration mismatches and issues with Nuxt Image and IPX, such as this issue, where users discuss hydration and rendering inconsistencies, but not the precise 1x
/2x
srcset
difference you described.
If you are looking for an issue that matches your case exactly, the knowledge sources do not contain one. You may consider opening a new issue on the Nuxt Image repository if you want to track or report this specific problem.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@434825695496241153> Kapa.ai is still learning and improving, please let me know how I did by reacting below.