Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(nuxt)!: allow app:rendered to modify ssr context and add render:html - #6521

Merged
pi0 merged 6 commits into
mainfrom
fix/app-render-modification
Aug 11, 2022
Merged

fix(nuxt)!: allow app:rendered to modify ssr context and add render:html#6521
pi0 merged 6 commits into
mainfrom
fix/app-render-modification

Conversation

@pi0

@pi0pi0 commented Aug 11, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

Resolvesnuxt/nuxt#14537

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • [x 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

We were calling app:rendered hook just after ssr rendering is being done in Nuxt 3 <= 3.0.0-rc.6. #6042 changed this behavior in v3.0.0-rc.7 that app:rendered is being called with new rendered context to have access to constructed html but this means, it is too late to modify payload.

This PR reverts app:rendered back to previous behavior with new limited { ssrContext } context only. (breaking change)

Nitro plugins have access to the final rendered context via render:html (breaking change: nuxt:app:rendered renamed for nitro plugins to be simpler, consistent with render:response hook and not confused with app:rendered lifecycle hook)

Example usage: (nitro plugin)

// server/plugins/render.tsexportdefaultdefineNitroPlugin((nitroApp)=>{nitroApp.hooks.hook('render:html',(html,{ event })=>{console.log({ html })})nitroApp.hooks.hook('render:response',(response,{ event })=>{console.log(response)})})

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify

netlifyBot commented Aug 11, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitcd24408
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62f5232c6cc9d600087a247a

@pi0
pi0 requested a review from danielroeAugust 11, 2022 15:13
@pi0pi0 changed the title fix(nuxt)!: allow app:rendered hook to modify ssr contextfix(nuxt)!: allow app:rendered to modify ssr context and add render:htmlAug 11, 2022
@pi0pi0 mentioned this pull request Aug 11, 2022
Comment threadpackages/nuxt/src/core/runtime/nitro/renderer.ts
Comment threadtest/fixtures/basic/nuxt.d.ts Outdated
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssrContext effectively read-only in app:rendered hook 3.0.0-rc.7

3 participants

@pi0@matthewhardern@danielroe