`useData` composable
See original GitHub issueContext: https://github.com/nuxt/framework/issues/7562, https://github.com/nuxt/framework/issues/7562
useState
is primarily to preserve initial state between client and server. useAsyncData
should be ideally used to store data but sometimes, it is more convenient to use useState
and direct async logic to fill it. (usage in nuxt/content document-driven mode).
We can introduce new useData
composable that acts almost same as useState
but is explicitly marked as page data and can be extracted to the static payloads.
Alternatives:
useState
to always be extracted (like 3.0.0.rc.1) => It introduces network when it is really initial state and same between pagesuseState
to track changes => Not sure if possible at all for server but even if is, a custom async logic might initializes it before composable. It also makes implementation more complex internallyuseAsyncData
=> Seems not fitting for all
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Already Composable
Use data orchestration to execute a multi-head strategy and gain synergy. Not all platforms are truly composable.
Read more >Jetpack Compose: How to handle states inside a ...
state is used to locally mutate and use data within the composition context. We'll focus on state function for our topic. Remember function ......
Read more >10 things you need to know before implementing ...
Composable analytics is the term used to describe the ability to assemble analytical models by combining data and operations from multiple sources.
Read more >Composables | Vue Storefront 2 for Magento
Usage. Let's see how you can use the useUser composable to load the current user's data: <script> ...
Read more >The Emergence of the Composable Customer Data Platform
... with having to use data engineering tools that are native to the CDP, ... Composable CDP with Snowplow, Databricks, and Hightouch ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(talking in context of full-static)
With #7567,
useState
will not be cleared on navuseData
is same asuseAsyncData
only not having an async fetcher and can be replaced for current implementation in nuxt/content ofuseState
. Content modules shall useuseData
with keys specific to each page for state that is variant to each page. This way it won’t be overridden but cached on CSR nav.@pi0 thx, but if i use the combination of useState and $fetch then i lose the useAsyncData functionality like { server: true | false}, lazy:true.
So i have to duplicate the whole functionality fetching the data and store them