N
Nuxt8mo ago
whoisthiru

What is the equivalent of vue-renderer:ssr:context hook in nuxt3?

In nuxt2, I have used vue-renderer:ssr:context to access the renderContext of a page. e.g. in ~/modules/someModule.js
let records = []

// collect data from each page and push it to an array.
this.nuxt.hook('vue-renderer:ssr:context', (renderContext) => {
const pageData = renderContext.nuxt.data[0]?.page,
const routePath = renderContext.nuxt.routePath,
records.push({pageData, routePath})
});

// Once generation is done, push the records to an endpoint
this.nuxt.hook('generate:done', async (generator, errors) => {
logger.info('generate:done');
// await db.saveObjects(records);
})
let records = []

// collect data from each page and push it to an array.
this.nuxt.hook('vue-renderer:ssr:context', (renderContext) => {
const pageData = renderContext.nuxt.data[0]?.page,
const routePath = renderContext.nuxt.routePath,
records.push({pageData, routePath})
});

// Once generation is done, push the records to an endpoint
this.nuxt.hook('generate:done', async (generator, errors) => {
logger.info('generate:done');
// await db.saveObjects(records);
})
I think app:rendered is the equivalent of generate:done hook in nuxt3. What is the equivalent of the hook vue-renderer:ssr:context, I could use in a nuxt 3 module? If there is no equivalent hook, what would be the recommended approach to do the same thing?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server