Skip to content

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

@art-boer

Description

@art-boer

Environment


  • Operating System: Darwin
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.7
  • Package Manager: npm@8.13.2
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-2wanhk?file=plugins/test.client.ts

Describe the bug

Not sure if this is a bug or if it is intentional. However, in the previous version of the app:rendered hook the ssrContext was mutable.

Using the app:rendered hook you can access the HTML including ssrContext, however, you cannot mutate its value. It seems like the HTML is already generated at this point, and no longer mutable.

nuxtApp.hook('app:rendered', ({ssrContext}) => { ssrContext.payload.state.test = 'test'; });

console.log(window.__NUXT__.state.test) -> undefined

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions