Druxt
The core module, DruxtClient, DruxtStore and the DruxtModule base component.
Druxt
The core druxt package is the foundation every other Druxt module builds
on. It provides the three pieces the whole framework shares:
- DruxtClient: the Drupal JSON:API communication layer.
- DruxtStore: the Vuex module caching resources and collections for all modules.
- DruxtModule: the base component behind the theme-component suggestion system.
Installation
-
Download the module:
npm i druxt -
Add the module and your backend URL to
nuxt.config.js:export default { modules: [['druxt', { baseUrl: 'https://demo-api.druxtjs.org' }]], };* Replace
https://demo-api.druxtjs.orgwith your own Drupal backend. -
On the Drupal side, install and enable the Druxt module and grant the access druxt resources permission to the relevant roles. Missing this is the most common cause of site-wide JSON:API failures. See Troubleshooting if requests are failing after install.
Settings
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | The Drupal backend URL. Required. | |
endpoint | string | 'jsonapi' | The JSON:API endpoint path. |
proxy.api | boolean | false | Proxy API requests via Nuxt (guide). |
proxy.files | boolean|string | false | Proxy Drupal files. A string sets the site. |
See the Nuxt module API for the full options list.
DruxtClient
The client is the communication layer between your application and Drupal's JSON:API: resources, collections, indexing and authentication all flow through it.
import { DruxtClient } from 'druxt';
const client = new DruxtClient('https://demo-api.druxtjs.org');
const collection = await client.getCollection('node--article');
- Use the Druxt client directly: practical guide, including non-Nuxt usage.
- DruxtClient API: full method reference.
DruxtStore
The Vuex module that all Druxt modules share: request deduplication, the resource/collection cache, and include handling.
const resource = await this.$store.dispatch('druxt/getResource', {
type: 'node--article',
id: 'd8dfd355-7f2f-4fc3-a149-288e4e293bdd',
});
- The DruxtStore concept page: how it works and why it exists.
- DruxtStore API: mutations and actions.
- Deprecations: retired signatures.
DruxtModule
The base component for all Druxt components: it turns a druxt() options
object (component suggestions, props, slots) into themeable rendering.
Building on it is covered by the
custom module tutorial, and the mechanism
by Component resolution.
Where to go next
- New to Druxt? Start with the Getting started tutorial.
- Ready for the full site experience? See the Site module.
Package README
The full npm package README (features, badges, install) is mirrored as the generated package README page.