-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
docs: clarify usage of await with useFetch #33745
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
base: main
Are you sure you want to change the base?
Conversation
Explain the pros and cons of awaiting useFetch
|
|
WalkthroughThis change updates the useFetch documentation to clarify usage and runtime behaviour. It adds notes that awaiting useFetch is not required for SSR (Nuxt will await the underlying promise) and that omitting await changes client‑side behaviour (immediate navigation and manual loading state management). It clarifies that Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-09-10T14:42:56.647ZApplied to files:
🪛 LanguageTooldocs/4.api/2.composables/use-fetch.md[uncategorized] ~34-~34: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION) [uncategorized] ~36-~36: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION) 🔇 Additional comments (3)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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: 0
🧹 Nitpick comments (1)
docs/4.api/2.composables/use-fetch.md (1)
32-35: Add a comma in the compound sentence for clarity.Line 34 contains a compound sentence that would benefit from a comma before the second independent clause for proper punctuation and readability.
Apply this diff:
-If you omit the `await`, navigation will happen immediately and you will have to handle loading states on your own. This will usually result in a better UX for your app but also means more effort. +If you omit the `await`, navigation will happen immediately, and you will have to handle loading states on your own. This will usually result in a better UX for your app but also means more effort.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/4.api/2.composables/use-fetch.md(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 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/4.api/2.composables/use-fetch.md
🪛 LanguageTool
docs/4.api/2.composables/use-fetch.md
[uncategorized] ~34-~34: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ait`, navigation will happen immediately and you will have to handle loading states ...
(COMMA_COMPOUND_SENTENCE)
[uncategorized] ~34-~34: Loose punctuation mark.
Context: ...or your app but also means more effort. :: ::note data, status, and error ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~36-~36: Loose punctuation mark.
Context: ...our app but also means more effort. :: ::note data, status, and error are ...
(UNLIKELY_OPENING_PUNCTUATION)
🔇 Additional comments (1)
docs/4.api/2.composables/use-fetch.md (1)
32-39: Well-structured documentation clarifying awaiting behaviour.The new note block directly addresses the gap in documentation regarding whether
useFetchmust be awaited. The explanation of the trade-off—improved UX through immediate navigation versus requiring manual loading state management—clearly communicates the implications of both patterns. The placement logically follows the custom wrapper warning and precedes the ref access clarification, making the flow coherent.
|
I would also add this note on |
Yes - this note may be better suited as a section on https://nuxt.com/docs/4.x/getting-started/data-fetching and it can also tie into usage of NuxtLoadingIndicator. |
Explain the pros and cons of awaiting useFetch
🔗 Linked issue
Well, just a discussion:
#33736 (reply in thread)
📚 Description
useFetch does not need to be awaited. It sometimes might even lead to better UX not to await it.
However, the docs only ever show useFetch being awaited and dont explain the implications.
Therefore I added a note explaining it a bit more.
Maybe we should put another note on useAsyncData?