Skip to content

The core module, DruxtClient, DruxtStore and the DruxtModule base component.

DruxtNuxtModule

View source on GitHub

DruxtNuxtModule(moduleOptions)

Nuxt module function to install Druxt.

Kind: global function

ParamTypeDescription
moduleOptionsModuleOptionsDruxtJS module options.

Example (Nuxt configuration with module options)

module.exports = {
  modules: [
    ['druxt', { baseUrl: 'https://api.umami.demo.druxtjs.org' }]
  ]
}

Example (Nuxt configuration with root level options)

module.exports = {
  modules: [
    'druxt'
  ],
  druxt: {
    baseUrl: 'https://api.umami.demo.druxtjs.org'
  }
}

ModuleOptions : object

Module options object.

Kind: global typedef
Properties

NameTypeDefaultDescription
baseUrlstringThe Base URL of the Drupal JSON:API backend.
[endpoint]string"/jsonapi"The JSON:API endpoint path.
[proxy]objectProxy settings object.
[proxy.api]booleanProxy the JSON:API.
[proxy.files]boolean | stringProxy Drupal's site files directory. Provide String to specify multi-site path.
[cache]object | booleanServer-side cache of the JSON:API index and menus, and with cache.content every other response, shared between requests that do not send an Authorization header, basic auth or a session cookie. Each response is kept for as long as Drupal's Cache-Control header allows, which is never on a site whose page cache max-age is 0. Off under nuxt dev. false turns it off.
[cache.content]booleanfalseAlso keep entities, collections, views and route lookups, under the same rules. Pair it with a clear from Drupal, as content changes far more often than menus.
[cache.maxSize]number52428800Bytes of responses each cache area keeps, measured as stored JSON. Past it the least recently used go first, and a response larger than the limit is not kept.
[cache.ttl]numberSeconds a cached response may live at most. It shortens Drupal's lifetime, never extends it.
[cache.secret]stringTurns on POST /_druxt/cache/clear, which empties the cache when the X-Druxt-Secret header matches. It stays on the server and is never sent to the browser.
[cache.sessionCookie]string"S?SESS[0-9a-f]+"A pattern for the name of the backend's session cookie. A request with a matching cookie never uses the cache.

Example

export default {
  modules: ['druxt'],
  druxt: {
    baseUrl: 'https://api.umami.demo.druxtjs.org',
    endpoint: '/jsonapi',
    proxy: {
      api: true,
      files: 'default'
    }
  }
}