-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Allow hooking into render context #14182
Copy link
Copy link
Closed
nuxt/framework
#6042Description
Sometimes it is necessary (especially for module authors) to hook into the renderer and do modifications or access the rendered HTML outside of the app lifecycle (making it possible to extend for SPA mode as well and write code in server context). We can allow this using nitro plugins hooking into renderer. I'm proposing two new server/nitro hooks:
nuxt:render:rendered (context: NuxtRenderContext)(Allow the modification and extension to the render result before compiling the template.htmlis unset)nuxt:render:html (html: string, context: NuxtRenderContext)(read-only access to final rendered html. modification is prohibited by design to avoid heavy string concatenation and preferring small context appending)
Notes:
- Would worth to add
ssrContexttoRenderResult. - We might rename
RenderResultinterface toNuxtRenderContextbefore exposing RenderResult.htmltype was never used. I'm proposing to remove it to make types less confusing.- We might introduce other types of render results (such as
payload) in the future.
Reactions are currently unavailable