Setup

Check the Nuxt.js documentation for more information about installing and using modules in Nuxt.js.

Installation

Add @voorhoede/nuxt-preview-mode-module dependency to your project:

yarn add @voorhoede/nuxt-preview-mode-module
npm install @voorhoede/nuxt-preview-mode-module

Then, add @voorhoede/nuxt-preview-mode-module to the modules section of nuxt.config.js:

nuxt.config.js
export default {
  modules: [
    '@voorhoede/nuxt-preview-mode-module'
  ],
  previewMode: {
    // preview secret is required and has no default:
    previewSecret: 'add your own secret here',
    // other options with their default values:
    persistent: true,
    storageType: 'localStorage',
    storageKey: 'nuxt-datocms-preview-data',
  }
}

or using shorthand options:

nuxt.config.js
export default {
  modules: [
    ['@voorhoede/nuxt-preview-mode-module', {
      // preview secret is required and has no default:
      previewSecret: 'add your own secret here',
      // other options with their default values:
      persistent: true,
      storageType: 'localStorage',
      storageKey: 'nuxt-datocms-preview-data',
    }]
  ],
}

Options

previewSecret

  • Required: true

String to match previewSecret query parameter to.

persistent

  • Default: true

Boolean defining whether to persist preview mode, using local storage (or session storage).

storageType

  • Default: localStorage
  • Can be either localStorage or sessionStorage

storageKey

  • Default: nuxt-datocms-preview-data
  • String setting the storage key for persisting preview data in localstorage or session storage.
Edit this page on GitHub Updated at Wed, Jun 21, 2023