All Projects → DreaMinder → Nuxt Payload Extractor

DreaMinder / Nuxt Payload Extractor

Licence: mit
Nuxt.js module that makes `nuxt generate` command to store html and payload separately.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nuxt Payload Extractor

Vue Api Query
💎 Elegant and simple way to build requests for REST API
Stars: ✭ 1,528 (+991.43%)
Mutual labels:  nuxt, nuxtjs
Blog Module
Build your blog with @nuxt
Stars: ✭ 130 (-7.14%)
Mutual labels:  nuxt, nuxtjs
Dayjs Module
Official Day.js module for your Nuxt.js project.
Stars: ✭ 111 (-20.71%)
Mutual labels:  nuxt, nuxtjs
Lichter.io
My own website and CV
Stars: ✭ 105 (-25%)
Mutual labels:  nuxt, nuxtjs
Nuxpress
A Nuxt-based blogging engine and boilerplate
Stars: ✭ 135 (-3.57%)
Mutual labels:  nuxt, nuxtjs
Google Gtag Module
Enable google gtagjs for NuxtJs
Stars: ✭ 106 (-24.29%)
Mutual labels:  nuxt, nuxtjs
Contenta vue nuxt
Start in minutes a Drupal 8 with JSON API and Vue.js : a Nuxt.js ( Vue.js SSR ) consumer for Contenta CMS
Stars: ✭ 125 (-10.71%)
Mutual labels:  nuxt, nuxtjs
Sails Nuxt
Sails + Nuxt + Vuetify Combo <3
Stars: ✭ 92 (-34.29%)
Mutual labels:  nuxt, nuxtjs
Jellyfin Vue
A modern web client for Jellyfin based on Vue.
Stars: ✭ 129 (-7.86%)
Mutual labels:  nuxt, nuxtjs
Nuxt Dev To Clone
Build DEV.TO clone with Nuxt.js and new `fetch` hook
Stars: ✭ 118 (-15.71%)
Mutual labels:  nuxt, nuxtjs
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-25%)
Mutual labels:  nuxt, nuxtjs
Vue State Store
📮 VSS (Vue State Store) - Vue State Management (with Publish & Subscribe pattern)
Stars: ✭ 128 (-8.57%)
Mutual labels:  nuxt, nuxtjs
Nuxt User Agent
Nuxt.js module for handling User-Agent.
Stars: ✭ 102 (-27.14%)
Mutual labels:  nuxt, nuxtjs
Nuxt Helmet
👷 Helmet for Nuxt
Stars: ✭ 126 (-10%)
Mutual labels:  nuxt, nuxtjs
Nuxt Netlify
Dynamically generate `_headers` and `_redirects` files for Netlify in your Nuxt.js projects
Stars: ✭ 97 (-30.71%)
Mutual labels:  nuxt, nuxtjs
Infoboard
Infoboard showing time, weather, calendar events, photos from local folder or online sources as background and Transport for London status updates. Intended for Raspberry Pi, but should work on any machine with NodeJS available.
Stars: ✭ 111 (-20.71%)
Mutual labels:  nuxt, nuxtjs
Nuxt Graphql Request
Easy Minimal GraphQL client integration with Nuxt.js.
Stars: ✭ 85 (-39.29%)
Mutual labels:  nuxt, nuxtjs
Example Ecommerce Snipcart Vue
The Transglobal Candy Store: Sample front-end for the Sanity.io e-commerce schema with vue.js, nuxt.js, and snipcart
Stars: ✭ 89 (-36.43%)
Mutual labels:  nuxt, nuxtjs
Bitwave
Front end for [bitwave.tv] - an open platform live video streaming service
Stars: ✭ 113 (-19.29%)
Mutual labels:  nuxt, nuxtjs
Surmon.me
🆒 My personal website and blog, powered by @vuejs (3)
Stars: ✭ 1,767 (+1162.14%)
Mutual labels:  nuxt, nuxtjs

Nuxt payload extractor

Nuxt.js module that makes nuxt generate command to store data payload in dist dir implementing full static generation. See it in action on my site: DreaMinder.pro

⚠️⚠️⚠️ This feature called "full static generated mode" has been released as a native Nuxt.js feature recently. You might want to try it out before using this module, it is much more powerful. ⚠️⚠️⚠️

Benefits

✓ If you use external API to fill your project with data, even after your site has been prerendered, you need to keep your API running to make client-side navigation possible. With this module your API data stores along with prerendered HTML, so the issue is solved

✓ Increases page download speed for crawlers

✓ Makes HTML source code look cleaner

✓ Decreases load on API server

✓ Makes prerendered and client rendered pages consistent in case API data changed after you deployed prerendered pages

✓ Decreases initial page download time x1.5-2 (which is actually doesn't affect perfomance)

Setup

  • Add nuxt-payload-extractor dependency
  • Define nuxt module:
{
  modules: [
   'nuxt-payload-extractor'
  ]
}
  • Add asyncData custom logic with $payloadURL helper
async asyncData({ $axios, $payloadURL, route }){
  //if generated and works as client navigation, fetch previously saved static JSON payload
  if(process.static && process.client && $payloadURL)
    return await $axios.$get($payloadURL(route))

  //your request logic
  let post = await $axios.$get(`/post.json`)
  return {
    post
  }
}
  • Run npm run generate

GraphQL usage

You'll need axios in your production bundle, your graphQL client is only invoked server-side, on 'generate' command.

async asyncData({ $axios, $payloadURL, route, app }) {
  if (process.static && process.client && $payloadURL) {
    return await $axios.$get($payloadURL(route))
  } else {
    let gqlData = await app.apolloProvider.defaultClient.query({
      query: gqlquery
    })
    return {
      gqlData
    }
  }
}

Options

You can blacklist specific paths using blacklist: [] options. They will be generated in native way. But you have to disable payload request inside of asyncData yourself. Check out example dir for details.

All payloads have timestamp applied to their names for better cache invalidation. You can turn them off by using versioning: false option. Keep in mind that timestamp changes on every generate run. Also, nuxt generate --no-build is not supported in this case.

Caveats

  • Are you using nested routes (with <nuxt-child />)? This case isn't compatible with nuxt-payload-extractor. It will only work if parent and child routes return different data-keys (ex. return { postsList } and return { singlePost }).
  • Are you filling your vuex store with page-specific data? It will break on client-side navigation. Use NuxtServerInit action for global vuex data or return your vuex data from asyncData to make it work.

How it works

  • Extracts <script>window.__NUXT__= ... </script> replacing it with <script src="payload.js">
  • Makes two files along with index.html of a prerendered page: payload.js for initial page load and payload.json for client-side navigation
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].