Skip to content

Drupal router for Nuxt, powered by the Drupal Decoupled Router module.

CI Known Vulnerabilities codecov

DruxtRouter connects Nuxt routing to Drupal routing. A wildcard route catches requests, resolves them through Drupal's Decoupled Router with path aliases and redirects included, and renders the matching Druxt component for the resolved entity or view. Your Nuxt pages/ directory keeps working alongside it, so a custom page can take over any route.

Features

  • Vue.js components:
    • DruxtRouter: Renders a Druxt component for the resolved Decoupled route
  • Route providers:
    • Content entity routes resolve DruxtEntity components
    • Drupal Views page routes resolve DruxtView components

Installation

  1. Install the package:

    npm i druxt-router
    
  2. Add the module to nuxt.config.js:

    export default {
      modules: ['druxt-router/nuxt'],
    };
    

Options

  • druxt.router.middleware

    Type: boolean
    Default: true

    Controls whether to execute the Route page middleware and process redirects.

  • druxt.router.pages

    Type: boolean
    Default: true if pages/ directory exists, else false

    Controls whether the Nuxt pages/ directory is used to generate routes.

  • druxt.router.wildcard

    Type: boolean
    Default: true

    Controls whether the wildcard route should be installed into the Nuxt/Vue router.


Vue.js components

DruxtRouter

Renders a Druxt module router component based on the resolved route provided by the Drupal Decoupled Router module.

<DruxtRouter path="/" />

If no Path is provided, the component will default to the Vue router fullpath.


Deprecations

Retired DruxtRouter client pass-through methods and druxtRouter store resource members, with their replacements, are listed on the deprecations page.


Options

Druxt Router options

These options are specific to this module.

OptionTypeRequiredDefaultDescription
router.middlewarebooleanNotrueWhether to run the Route page middleware and redirects.
router.pagesbooleanNotrue if pages/ existsWhether to parse the Nuxt pages/ directory.
router.wildcardbooleanNotrueWhether to install the wildcard route.

Base Druxt options

These options are available to all DruxtJS modules.

OptionTypeRequiredDefaultDescription
axiosobjectNo{}Axios instance settings.
baseUrlstringYesnullBase URL for the Drupal installation.
endpointstringNo/jsonapiJSON:API Endpoint of the Drupal installation.

Note: The contents of this file were automatically generated from the packages/router/README.md.