Accessing rendered HTML in Nuxt hook in order to process and potentially modify final HTML output
See original GitHub issueDescribe the feature
There was a brief moment during RC7 where the app:rendered
hook was called with the constructed HTML output at which point we were able to access the output and modify it if necessary. In Nuxt 2, we made use of the vue-renderer:ssr:templateParams
hook for this purpose. Our specific use-case is to process the final HTML with Twind to transform our CSS classes and to inject a stylesheet into the head. We’re not interested in modifying the ssrContext at this point.
If there is a way to bring back this functionality, it would be greatly appreciated.
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read the contribution guide.
- Check existing discussions and issues.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Nuxt Lifecycle
The generation process starts ( nuxt generate ); Nuxt hooks; serverMiddleware; Server-side Nuxt plugins. in order as defined in nuxt.config.js.
Read more >Nuxt.js for Busy Developers - CODE Magazine
The original html file that the client-side receives from the server is just a blank page! The client sends additional requests to the...
Read more >Creating Server-side Rendered Vue.js Apps Using Nuxt.js
In order to grasp the potential of Nuxt, let's create a simple project. The final source code for this project is hosted on...
Read more >HTML Standard
These are guaranteed to never be touched by browsers, and allow scripts to include data on HTML elements that scripts can then look...
Read more >What to do when Vue hydration fails - Alexander Lichter's blog
Find the element causing the hydration error · Ensure your HTML is valid · Resolving state inconsistencies between server and client · Final...
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
Glad you liked the module 😊 And sure your usecase makes sense and we can make it working using event context. Do you mind to open an issue in my moduls? i can give more details if you like to help on implementing this mode 👍
OK, first off, you are amazing @pi0 ! I find it hilarious that I wake up this morning to see that you’ve come so far as to create a Nuxt module for Twind integration 😄
I am excited to try it out! In the meantime, I just wanted to say thank you for looking into this and let you know a brief rundown of how I’m using Twind.
I’m using it in Library Mode where I’ve created a plugin to build my global utility that I use to apply styles to all of my components.
The plugin code looks a little something like this:
This does a few things for me:
My intention with the
app:rendered
hook was to provide this instance to the extract function (that you’ve used for your module) in order to process my app’s HTML output.The reason why I believed using the same instance is important is because Twind’s virtual sheet (used server-side) includes “resume data” that the Twind runtime can use to avoid duplicating the work client-side. What I’m not sure of is whether or not this data is unique to the instance or is generated in a way that simply creating another instance for the Nitro plugin with the same config would be enough…
So when I get a chance, I’ll fire up a sandbox and test some stuff out with your module. I honestly believe you’ve given me all the tools I’d need to make this work. Thank you so much! 🙏
I’ll report back with my findings. 👍