Nuxt.js module that makes `nuxt generate` command to store html and payload separately.
The Nuxt payload extractor is a module for Nuxt.js that allows for the storing of data payload in the dist directory during the generation process. This implementation enables full static generation and improves page download speed for crawlers. It also makes the HTML source code cleaner and decreases the load on the API server. Additionally, it ensures consistency between prerendered and client-rendered pages in case the API data changes after the deployment of prerendered pages. The module decreases the initial page download time by 1.5-2 times without affecting performance.
To install the Nuxt payload extractor, follow these steps:
nuxt-payload-extractor dependency to your project.npm install nuxt-payload-extractor
// nuxt.config.js
export default {
modules: ['nuxt-payload-extractor'],
// Other Nuxt configuration...
}
$payloadURL helper.// pages/index.vue
export default {
async asyncData({ $payloadURL }) {
const data = await fetch($payloadURL('/api/data'))
return { data }
}
// Other component properties...
}
npm run generate command to generate the static files with the payload.npm run generate
The Nuxt payload extractor is a module for Nuxt.js that allows for the storing of data payload in the dist directory during the generation process. This feature, called “full static generated mode,” provides benefits such as improved page download speed for crawlers, cleaner HTML source code, reduced load on the API server, and consistency between prerendered and client-rendered pages. The module decreases the initial page download time, enhancing the overall user experience. It is easy to install and can be integrated into existing Nuxt.js projects.