Skip to content

Conversation

huang-julien
Copy link
Member

🔗 Linked issue

📚 Description

An additionnal best practice page about hydration

@huang-julien huang-julien requested a review from danielroe as a code owner July 24, 2025 17:50
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.


Vue will log hydration mismatch warnings in the browser console during development:

![vue hydration warning in console](image.png)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops... guess i have to open a pr to nuxt.com first...

Copy link

coderabbitai bot commented Jul 24, 2025

Warning

Rate limit exceeded

@huang-julien has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 40 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3de9d97 and 425da97.

📒 Files selected for processing (1)
  • docs/2.guide/5.best-practices/hydration.md (1 hunks)

Walkthrough

A new documentation guide titled "Nuxt and hydration" has been introduced. This guide explains the significance of addressing hydration issues in Nuxt applications, details the negative consequences of hydration mismatches, and describes methods for detecting such issues. It lists common causes of hydration problems, provides illustrative code examples, and recommends solutions using Nuxt-specific composables and components. The document concludes with a summary of best practices and references to further reading.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/hydration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
docs/2.guide/5.best-practices/hydration.md (3)

4-4: Add missing verb in the description front-matter

The sentence is missing the verb “is”, which reads a little jarring in the docs header.

-description: Why fixing hydration issues important
+description: Why fixing hydration issues is important

15-15: Insert a comma after the subordinate clause

A short pause helps readability and resolves the LanguageTool warning.

-  - **Increased time to interactive**: Hydration errors force Vue to re-render the entire component tree which will increase the time for your Nuxt app to become interactive
+  - **Increased time to interactive**: Hydration errors force Vue to re-render the entire component tree, which will increase the time for your Nuxt app to become interactive

186-188: Separate the directive block with a newline to avoid “loose punctuation”

The two spaces before ::tip are interpreted as punctuation noise by the linter and may also break MD-enhanced parsers. A clean newline solves both problems.

-Avoid side effects in setup: Move browser-dependent code to `onMounted`
-
-::tip
+Avoid side effects in setup: Move browser-dependent code to `onMounted`
+
+
+::tip
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4317e0 and 53f8713.

⛔ Files ignored due to path filters (1)
  • docs/2.guide/5.best-practices/image.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • docs/2.guide/5.best-practices/hydration.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Tofandel
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/runtime/client-delayed-component.ts:62-62
Timestamp: 2024-11-05T20:04:39.622Z
Learning: In Vue components, when typing the `hydrate` prop for hydration strategies like `hydrateOnInteraction`, use `type: null as PropType<Arguments<typeof hydrateOnInteraction>[0]>` to get the type directly from Vue's hydration methods. Also, remember that `HTMLElementEventMap` is not a type but an object; use `keyof HTMLElementEventMap` when defining prop types for events.
docs/2.guide/5.best-practices/hydration.md (2)

Learnt from: Tofandel
PR: #26468
File: packages/nuxt/src/components/runtime/client-delayed-component.ts:62-62
Timestamp: 2024-11-05T20:04:39.622Z
Learning: In Vue components, when typing the hydrate prop for hydration strategies like hydrateOnInteraction, use type: null as PropType<Arguments<typeof hydrateOnInteraction>[0]> to get the type directly from Vue's hydration methods. Also, remember that HTMLElementEventMap is not a type but an object; use keyof HTMLElementEventMap when defining prop types for events.

Learnt from: huang-julien
PR: #29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In packages/nuxt/src/app/components/nuxt-root.vue, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null

instead of wrapping the import in a computed property or importing the component unconditionally.

🪛 LanguageTool
docs/2.guide/5.best-practices/hydration.md

[uncategorized] ~15-~15: Possible missing comma found.
Context: ...e Vue to re-render the entire component tree which will increase the time for your N...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~185-~185: Loose punctuation mark.
Context: ... browser-dependent code to onMounted ::tip You can read the [Vue documentation...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~187-~187: Loose punctuation mark.
Context: ...or a better understanding of hydration. ::

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint-docs
  • GitHub Check: lint-docs
🔇 Additional comments (1)
docs/2.guide/5.best-practices/hydration.md (1)

30-30: Verify that image.png is committed and has the right path

The document references image.png, but the file is not part of this PR. Broken image links render as empty blocks in prod docs.

Would you confirm that the screenshot is present in the repository’s static assets (e.g. docs/public/images/)? If not, please include it or adjust the path.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
docs/2.guide/5.best-practices/hydration.md (5)

4-4: Add missing verb in front-matter description

The sentence in the front-matter lacks the verb “is”, which slightly harms readability.

-description: Why fixing hydration issues important
+description: Why fixing hydration issues is important

15-16: Insert comma after non-restrictive clause

Add a comma after “component tree” to separate the non-restrictive clause and improve flow.

-...component tree which will increase the time for your Nuxt app...
+...component tree, which will increase the time for your Nuxt app...

24-31: Consider adding explicit alt text for accessibility

The image has an alt that repeats the filename. Replace it with a concise description of what the console warning shows so screen-reader users get meaningful context.

-![vue hydration warning in console](/assets/docs/best-practices/vue-console-hydration.png)
+![Screenshot of Vue hydration mismatch warning in the browser console](/assets/docs/best-practices/vue-console-hydration.png)

121-122: Grammar tweak in heading

“once hydration completed” is missing “has”. Also consider wording “after hydration has completed” for clarity.

-**Solution**: Initialize libraries once hydration completed:
+**Solution**: Initialise libraries after hydration has completed:

186-188: Minor admonition formatting

Many markdown parsers require a blank line before ::tip for proper block rendering; otherwise, it may be treated as plain text.

-4. **Avoid side effects in setup**: Move browser-dependent code to `onMounted`
-
-::tip
+4. **Avoid side effects in setup**: Move browser-dependent code to `onMounted`
+
+
+::tip
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53f8713 and 3de9d97.

📒 Files selected for processing (1)
  • docs/2.guide/5.best-practices/hydration.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Tofandel
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/runtime/client-delayed-component.ts:62-62
Timestamp: 2024-11-05T20:04:39.622Z
Learning: In Vue components, when typing the `hydrate` prop for hydration strategies like `hydrateOnInteraction`, use `type: null as PropType<Arguments<typeof hydrateOnInteraction>[0]>` to get the type directly from Vue's hydration methods. Also, remember that `HTMLElementEventMap` is not a type but an object; use `keyof HTMLElementEventMap` when defining prop types for events.
docs/2.guide/5.best-practices/hydration.md (2)

Learnt from: Tofandel
PR: #26468
File: packages/nuxt/src/components/runtime/client-delayed-component.ts:62-62
Timestamp: 2024-11-05T20:04:39.622Z
Learning: In Vue components, when typing the hydrate prop for hydration strategies like hydrateOnInteraction, use type: null as PropType<Arguments<typeof hydrateOnInteraction>[0]> to get the type directly from Vue's hydration methods. Also, remember that HTMLElementEventMap is not a type but an object; use keyof HTMLElementEventMap when defining prop types for events.

Learnt from: huang-julien
PR: #29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In packages/nuxt/src/app/components/nuxt-root.vue, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null

instead of wrapping the import in a computed property or importing the component unconditionally.

🪛 LanguageTool
docs/2.guide/5.best-practices/hydration.md

[uncategorized] ~15-~15: Possible missing comma found.
Context: ...e Vue to re-render the entire component tree which will increase the time for your N...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~185-~185: Loose punctuation mark.
Context: ... browser-dependent code to onMounted ::tip You can read the [Vue documentation...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~187-~187: Loose punctuation mark.
Context: ...or a better understanding of hydration. ::

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint-docs
  • GitHub Check: lint-docs

@danielroe danielroe merged commit 2111b18 into main Jul 25, 2025
8 of 9 checks passed
@danielroe danielroe deleted the docs/hydration branch July 25, 2025 07:55
@github-actions github-actions bot mentioned this pull request Jul 25, 2025
danielroe pushed a commit that referenced this pull request Jul 25, 2025
@github-actions github-actions bot mentioned this pull request Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants