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
feat(vue-app): context.beforeSerialize
method
#9332
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #9332 +/- ##
=======================================
Coverage 65.15% 65.15%
=======================================
Files 94 94
Lines 4107 4107
Branches 1125 1125
=======================================
Hits 2676 2676
Misses 1153 1153
Partials 278 278
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
Hi @dovca Thank you for the pull request, I believe this is a nice implementation and needed since the new I let Pooya and Daniel take a look too at it, if good, you can start adding a PR to nuxt/nuxtjs.org repo to document it. |
Another thing in mind, we may also just move
EDIT: we have no choice since using a method in |
Ideally, we should have One solution might be to rename |
We can keep |
context.beforeSerialize
method
Related to nuxt/nuxt#9332
Added the PR for docs: nuxt/website-v2#1475 |
context.beforeSerialize
methodcontext.beforeSerialize
method
Hi, when will this be released? |
Hi @fabis94 it will be released with 2.16 (next minor -- no eta now) but in the meantime, you can try switching from |
Edited by @Atinux
Types of changes
Description
This PR adds a
beforeSerialize
method in the context that can be used to modifywindow.__NUXT__
after waiting forserverPrefetch
,fetch
andasyncData
, store actions and so on. This will solve hydration issues with plugins like @nuxtjs/apollo and others.beforeSerialize
expects a function to be synchronous now since therendered
method is synchronous in Vue: https://github.com/vuejs/vue/blob/dev/src/server/create-renderer.js#L89The official documented way to wait until the ssr renderer has finished and inject the final state is using ssrContext.rendered.
Resolves: #9155, resolves #8620, resolves #8852 and possibly resolves nuxt-modules/apollo#352 after some more work in that repo.
Checklist:
Will be happy to write up the docs if/when this gets accepted.