You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hydration mismatch because of different "newline" #2000
Thanks for the information. I'm currently trying to find the location in the code where the file is read / before Vue gets the data.
As a temporary fix, that's probably much simpler than a custom content renderer I suggest you to use the content:file:beforeParse hook. To get it to work, you have to remove the .nuxt directory of your project once to delete cached files.
Here'd be the code snippet to replace CRLF line endings of Markdown files with LF:
// e.g. server/plugins/crlf-to-lf.tsexportdefaultdefineNitroPlugin((nitroApp)=>{nitroApp.hooks.hook('content:file:beforeParse',(file)=>{if(file._id.endsWith('.md')){file.body=file.body.replace(/\r\n|\r/g,'\n')}})})
Just stumbled on the issue that newLine is not displayed in the browser.
Solution is to set the whitespace to pre-line in css <ContentRenderer :value="data || {}" :style="{ whiteSpace: 'pre-line' }" />
or with tailwind if you use that <ContentRenderer :value="data || {}" class="whitespace-pre-line" />
To fix the hydration issue just change the server's newLine to \n to match the browser
Whereby LF is \n and CRLF is \r\n
Activity
bjerggaard commentedon Apr 20, 2023
I experienced this as well
skoenfaelt commentedon Apr 20, 2023
A workaround for that until a fix arrives is to use
lfas end of lineI setup it in .editorconfig and .prettierrc so it gets automatically "fixed" by the ide and commands.
nobkd commentedon Jun 17, 2023
I tried to reproduce this issue, and as far as I can see, the hydration mismatch only happens with code blocks.
Does that match your experience?
stenet commentedon Jun 21, 2023
@nobkd no, in my case it's a simple markdown file:
https://github.com/stenet/nuxt-content-hydration-mismatch/blob/22090964fb19849d8b94ce3e175c287a7d4efcb5/content/index.md?plain=1#LL1C1-L1C1
nobkd commentedon Jun 24, 2023
Thanks for the information. I'm currently trying to find the location in the code where the file is read / before Vue gets the data.
As a temporary fix, that's probably much simpler than a custom content renderer I suggest you to use the
content:file:beforeParsehook. To get it to work, you have to remove the.nuxtdirectory of your project once to delete cached files.Here'd be the code snippet to replace CRLF line endings of Markdown files with LF:
dreamgear commentedon May 6, 2025
This is still happening in Nuxt 3.17.1. It's not code or md, but rather the data being fetched from my api:
`runtime-core.esm-bundler.js:51 [Vue warn]: Hydration text mismatch in <td data-pinned="false" class="...">…
I've gotten various suggestions on how to fix it, but I think the warnings would then resume when I deploy on Linux.
Rednas83 commentedon Jun 12, 2025
Just stumbled on the issue that
newLineis not displayed in the browser.Solution is to set the whitespace to
pre-linein css<ContentRenderer :value="data || {}" :style="{ whiteSpace: 'pre-line' }" />or with tailwind if you use that
<ContentRenderer :value="data || {}" class="whitespace-pre-line" />To fix the hydration issue just change the server's newLine to

\nto match the browserWhereby LF is
\nand CRLF is\r\n