Preview Mode not working anymore ion step "1st Approach: Full Static with Preview Mode"
In the step "1st Approach: Full Static with Preview Mode" of the tutorial Create a Preview Environment for Your Nuxt 3 Website, the following method is used to refetch-the draft version of the useAsyncData in [...slug].vue:
nuxtApp.hook('page:finish', () => { refreshNuxtData() });
This does not seem to be working anymore in the newer Nuxt versions. The solution is originally from this discussion, where the original author also states in a comment in May 2023, that the solution is not working anymore.
Possible solutions:
-
I think the problem would be easily solvable by adding the version to the
useAsyncDatakey in[...slug].vue. So using${locale.value}-${version}-${url}instead of${locale.value}-${url}. Because then Nuxt has to refetch thedraftversion on the client in edior mode, since theversionvariable is different from the server-generated one. -
Investigating Nuxt's relatively new composable
usePreviewModefor this would probably be a good (maybe best) solution. It has also been suggested by another user in this issue of the storyblok-nuxt package. -
The author of the obsolete solution also points to this as an alternative, but imho this is unnecessarily complicated.