-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
docs: enhance documentation for Nuxt composables #33626
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
Conversation
|
|
WalkthroughThis pull request expands and restructures documentation for five composables within the API reference: Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/3.api/2.composables/use-head-safe.md(3 hunks)docs/3.api/2.composables/use-head.md(2 hunks)docs/3.api/2.composables/use-hydration.md(3 hunks)docs/3.api/2.composables/use-lazy-async-data.md(1 hunks)docs/3.api/2.composables/use-lazy-fetch.md(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-10T14:42:56.647Z
Learnt from: Tofandel
Repo: nuxt/nuxt PR: 33192
File: test/nuxt/use-async-data.test.ts:366-373
Timestamp: 2025-09-10T14:42:56.647Z
Learning: In the Nuxt useAsyncData test "should watch params deeply in a non synchronous way", the foo watcher intentionally updates both params.foo and params.locale using locale.value, simulating a scenario where one watcher consolidates multiple reactive values into a shared params object for testing debounced/non-synchronous behavior.
Applied to files:
docs/3.api/2.composables/use-lazy-async-data.md
📚 Learning: 2024-11-05T20:04:39.622Z
Learnt from: Tofandel
Repo: nuxt/nuxt 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.
Applied to files:
docs/3.api/2.composables/use-hydration.md
🪛 LanguageTool
docs/3.api/2.composables/use-lazy-async-data.md
[uncategorized] ~12-~12: Loose punctuation mark.
Context: ...y setting the lazy option to true. ::note By default, [useAsyncData](/docs...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~14-~14: Loose punctuation mark.
Context: ...a fetching continues in the background. :: ## Usage ```vue [app/pages/index.vue...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~34-~34: Loose punctuation mark.
Context: ...ctly within your component's template. ::warning useLazyAsyncData is a reserve...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~36-~36: Loose punctuation mark.
Context: ...e your own function useLazyAsyncData. :: ## Type ```ts [Signature] export fun...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~59-~59: Loose punctuation mark.
Context: ...yoption automatically set totrue`. :read-more{to="/docs/4.x/api/composables/...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~65-~65: Loose punctuation mark.
Context: ...s/4.x/api/composables/use-async-data). :read-more{to="/docs/4.x/api/composables/...
(UNLIKELY_OPENING_PUNCTUATION)
docs/3.api/2.composables/use-head-safe.md
[uncategorized] ~30-~30: Loose punctuation mark.
Context: ..."0;javascript:alert(1)"> </script> ``` ::warning When using useHeadSafe, poten...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~32-~32: Loose punctuation mark.
Context: ...re working with user-generated content. :: ## Type ```ts [Signature] export fun...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~61-~61: Loose punctuation mark.
Context: ... detailed types. ## Parameters input: A MaybeComputedRef<HeadSafe> object c...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...sanitized }, ], }) </script> ``` ::read-more{to="https://unhead.unjs.io/do...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ead more on the Unhead documentation. ::
(UNLIKELY_OPENING_PUNCTUATION)
docs/3.api/2.composables/use-head.md
[uncategorized] ~29-~29: Loose punctuation mark.
Context: ...('Hello world')' }] }) </script> ``` ::warning If the data comes from a user o...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~31-~31: Loose punctuation mark.
Context: ...ocs/4.x/api/composables/use-head-safe). :: ::note The properties of useHead ca...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~33-~33: Loose punctuation mark.
Context: ...4.x/api/composables/use-head-safe). :: ::note The properties of useHead can be...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~35-~35: Loose punctuation mark.
Context: ...ect to make the entire object reactive. :: ## Type ```ts [Signature] export fun...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~61-~61: Loose punctuation mark.
Context: ...e detailed types. ## Parameters meta: An object accepting head metadata prope...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~66-~66: To form a complete sentence, be sure to include a subject or ‘there’.
Context: ...c template to customize the page title. Can be a string with %s placeholder or a ...
(MISSING_IT_THERE)
[misspelling] ~69-~69: This word is normally spelled as one.
Context: ...butes. | | meta | Meta[] | Array of meta objects. Each element is mapped to a <meta> t...
(EN_COMPOUNDS_META_OBJECTS)
[uncategorized] ~168-~168: Loose punctuation mark.
Context: ...ss: 'themed-page' } }) </script> ``` :read-more{to="/docs/4.x/getting-started/...
(UNLIKELY_OPENING_PUNCTUATION)
docs/3.api/2.composables/use-hydration.md
[uncategorized] ~11-~11: Possible missing comma found.
Context: ...eive that data on the client side. This way useHydration allows you to take full ...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~12-~12: Loose punctuation mark.
Context: ...e full control of the hydration cycle. ::note This is an advanced composable, pr...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~24-~24: Loose punctuation mark.
Context: ...g redundant computations or API calls. ::code-group ```ts [With useHydration] e...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~70-~70: Possible missing article found.
Context: ...ted only on the client (called when initial Vue instance is created) to receive the...
(AI_HYDRA_LEO_MISSING_THE)
docs/3.api/2.composables/use-lazy-fetch.md
[uncategorized] ~33-~33: Loose punctuation mark.
Context: ...-> ``` ::note useLazyFetch has the same signat...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~35-~35: Loose punctuation mark.
Context: ...](/docs/4.x/api/composables/use-fetch). :: ::warning Awaiting useLazyFetch onl...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~37-~37: Loose punctuation mark.
Context: ...ocs/4.x/api/composables/use-fetch). :: ::warning Awaiting useLazyFetch only en...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~39-~39: Loose punctuation mark.
Context: ...ngstate in your component's template. :: ::warninguseLazyFetch` is a reserve...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~41-~41: Loose punctuation mark.
Context: ...state in your component's template. :: ::warning useLazyFetch is a reserved fu...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~43-~43: Loose punctuation mark.
Context: ... name your own function useLazyFetch. :: ## Type ```ts [Signature] export fun...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~54-~54: Loose punctuation mark.
Context: ... Promise<AsyncData<DataT, ErrorT>> ``` ::note useLazyFetch is equivalent to `u...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~56-~56: Loose punctuation mark.
Context: ...s/use-fetch) for full type definitions. :: ## Parameters useLazyFetch accepts...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~65-~65: Loose punctuation mark.
Context: ...th lazy automatically set to true. :read-more{to="/docs/4.x/api/composables/...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~80-~80: Loose punctuation mark.
Context: ...`, and cancels any pending requests. | :read-more{to="/docs/4.x/api/composables/...
(UNLIKELY_OPENING_PUNCTUATION)
🔇 Additional comments (3)
docs/3.api/2.composables/use-hydration.md (2)
11-11: Minor grammar: missing article in parameter description.Line 11 contains accurate information, but the static analysis flag for line 70 is legitimate.
61-61: Type signature correction is accurate.The fix from
set: (value: T) => vtoset: (value: T) => voidis correct and necessary. The incorrectvwas a typo that would have caused confusion. ✓docs/3.api/2.composables/use-lazy-async-data.md (1)
1-90: Solid documentation enhancement with clear structure and accurate technical content.The restructured documentation effectively communicates the purpose and usage of
useLazyAsyncDatathrough well-organized sections. The Vue usage example (lines 19–31) correctly demonstrates proper destructuring ofstatusanddataproperties, whilst the template shows appropriate conditional rendering for pending and error states. The type signatures are presented clearly, the compiler warning about naming conventions is appropriate and useful, and cross-references to the parentuseAsyncDatacomposable maintain consistency without repeating detailed parameter documentation.The static analysis warnings flagged are false positives related to Markdown syntax elements (
::-delimited blocks and:read-more{}components), which are correct documentation formatting.
| | Property | Type | Description | | ||
| | --- | --- | --- | | ||
| | `title` | `string` | Sets the page title. | | ||
| | `titleTemplate` | `string \| ((title?: string) => string)` | Configures a dynamic template to customize the page title. Can be a string with `%s` placeholder or a function. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grammar: sentence lacks subject in parameters table.
Line 66 should include a subject pronoun. Current text: "Can be a string with…" should be: "It can be a string with %s placeholder or a function."
Apply this diff:
-| `titleTemplate` | `string \| ((title?: string) => string)` | Configures a dynamic template to customize the page title. Can be a string with `%s` placeholder or a function. |
+| `titleTemplate` | `string \| ((title?: string) => string)` | Configures a dynamic template to customise the page title. It can be a string with `%s` placeholder or a function. |📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| | Property | Type | Description | | |
| | --- | --- | --- | | |
| | `title` | `string` | Sets the page title. | | |
| | `titleTemplate` | `string \| ((title?: string) => string)` | Configures a dynamic template to customize the page title. Can be a string with `%s` placeholder or a function. | | |
| | Property | Type | Description | | |
| | --- | --- | --- | | |
| | `title` | `string` | Sets the page title. | | |
| | `titleTemplate` | `string \| ((title?: string) => string)` | Configures a dynamic template to customise the page title. It can be a string with `%s` placeholder or a function. | |
🧰 Tools
🪛 LanguageTool
[style] ~66-~66: To form a complete sentence, be sure to include a subject or ‘there’.
Context: ...c template to customize the page title. Can be a string with %s placeholder or a ...
(MISSING_IT_THERE)
🤖 Prompt for AI Agents
In docs/3.api/2.composables/use-head.md around lines 63 to 66, the parameters
table entry for titleTemplate uses the fragment "Can be a string with `%s`
placeholder or a function." — update that sentence to include a subject pronoun
by changing it to "It can be a string with `%s` placeholder or a function." so
the sentence is grammatically complete.
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | `key` | `string` | A unique key that identifies the data in your Nuxt application. | | ||
| | `get` | `() => T` | A function executed **only on the server** (called when SSR rendering is done) to set the initial value. | | ||
| | `set` | `(value: T) => void` | A function executed **only on the client** (called when initial Vue instance is created) to receive the data. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grammar: add missing article in parameter table.
Line 70 should read: "A function executed only on the client (called when the initial Vue instance is created)…"
Apply this diff:
-| `set` | `(value: T) => void` | A function executed **only on the client** (called when initial Vue instance is created) to receive the data. |
+| `set` | `(value: T) => void` | A function executed **only on the client** (called when the initial Vue instance is created) to receive the data. |📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| | Parameter | Type | Description | | |
| | --- | --- | --- | | |
| | `key` | `string` | A unique key that identifies the data in your Nuxt application. | | |
| | `get` | `() => T` | A function executed **only on the server** (called when SSR rendering is done) to set the initial value. | | |
| | `set` | `(value: T) => void` | A function executed **only on the client** (called when initial Vue instance is created) to receive the data. | | |
| | Parameter | Type | Description | | |
| | --- | --- | --- | | |
| | `key` | `string` | A unique key that identifies the data in your Nuxt application. | | |
| | `get` | `() => T` | A function executed **only on the server** (called when SSR rendering is done) to set the initial value. | | |
| | `set` | `(value: T) => void` | A function executed **only on the client** (called when the initial Vue instance is created) to receive the data. | |
🧰 Tools
🪛 LanguageTool
[uncategorized] ~70-~70: Possible missing article found.
Context: ...ted only on the client (called when initial Vue instance is created) to receive the...
(AI_HYDRA_LEO_MISSING_THE)
🤖 Prompt for AI Agents
In docs/3.api/2.composables/use-hydration.md around lines 66 to 70, the "set"
parameter description is missing the article "the"; update the text so it reads:
"A function executed **only on the client** (called when the initial Vue
instance is created) to receive the data." Replace the existing sentence
accordingly to include the article "the".
danielroe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you ❤️
🔗 Linked issue
Contributes to #30930
📚 Description
Improving the documentation for a few Nuxt composables according to the discussion at #30930