@slvrdigital/statics-prefetch

Nuxt.js module for static data prefetching

Usage no npm install needed!

<script type="module">
  import slvrdigitalStaticsPrefetch from 'https://cdn.skypack.dev/@slvrdigital/statics-prefetch';
</script>

README

@nuxtjs/ngrok

@slvrdigital/statics-prefetch

Features

  • Prefetch static data
  • Format response data

📖  Read more

Quick Setup

  1. Add @slvrdigital/statics-prefetch dependency to your project
npm install @slvrdigital/statics-prefetch # or yarn add @slvrdigital/statics-prefetch
  1. Add @slvrdigital/statics-prefetch to the buildModules section of nuxt.config.js (or modules if on Nuxt < 2.9>)
{
  buildModules: [
    '@slvrdigital/statics-prefetch',
  ],
}

Add Options

Add services config and more using the module options.

staticsPrefetch: {
  stopOnFail: false,
  serviceCollection: [
    {
      url: 'https://jsonplaceholder.typicode.com/posts',
      saveAs: 'posts.json'
    }
  ]
}

See module options.

Usage

Run the dev or build command and you will see pre-fetched data in the Nuxt CLI which you can then import and use in app.

Simple use example:

npm run dev # or npm run build
or
yarn dev # or yarn build

See Usage.

Development

  1. Clone this repository
  2. Install dependencies using npm install or yarn add
  3. Start development server using npm run dev or yarn dev

License

MIT License