npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

druxt-schema

v0.12.1

Published

Drupal Content Entity schema generator for Druxt with support for View and Form displays.

Readme

DruxtSchema

npm dev CI Known Vulnerabilities codecov

Drupal Content Entity schema generator for Druxt with support for View and Form displays.

DruxtSchema turns Drupal display configuration into build-time schemas. For each entity type, bundle and display mode it records which fields render, in what order and with which formatter settings, and stores the result in a Vuex store. The Entity module renders from these schemas at runtime, so your frontend follows Drupal's display configuration without querying it on every request.

Features

  • Generates schemas on build
  • Configurable schema filter
  • View and Form schemas

Installation

Included with druxt-site. Install it separately only when composing modules yourself.

  1. Install the package:

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

    export default {
      modules: ['druxt-schema'],
    };

Development releases

Every change merged to develop is published under the dev tag:

npm i druxt-schema@dev

These are unreleased builds. See development releases before using one.

Settings

Filter schemas

The Schema module will generate a schema for all available content entity type by bundle, display mode and schema type.

This generated schemas can be filtered by providing a druxt.schema.filter setting in the nuxt.config.js file:

export default {
  modules: ['druxt-schema'],
  druxt: {
    schema: {
      filter: [
        // List specific schema files to generate.
        'node--page--default--view',
        'media--image--square--view',
        // Or use a regular expression.
        '.*?--form',
      ],
    },
  },
};

Refresh schemas without a rebuild

Schemas are generated at build time, so a change to a display in Drupal needs a new build to show. Set druxt.schema.refresh to regenerate them on the Nuxt server instead:

export default {
  modules: ['druxt-schema'],
  druxt: {
    cache: { secret: process.env.DRUXT_CACHE_SECRET },
    schema: { refresh: true },
  },
};
  • The server regenerates a schema the first time a page needs it, and holds it until the next cache clear, POST /_druxt/cache/clear or druxt/clearCache. Have Drupal call the clear when configuration changes, as for content.
  • The browser asks the server for a schema at /_druxt/schema/<id> and never reads Drupal's configuration itself. The server generates with the same access the build uses.
  • Regeneration only covers schemas the build could generate. When it fails, the schema from the build is used.
  • The hold is per server process, so a site with several instances needs each one cleared.
  • A server started with a different base URL from its build still refreshes when it serves one site. A process serving several sites matches each by the base URL it was built with.
  • Under nuxt dev there is no cache to clear, so each request regenerates the schemas it uses.
  • A static site (nuxt generate) has no server and keeps the schemas from its build.

On your own server

A static site served by its own Node server can offer the same refresh. Serve the route the browser asks, and clear the held schemas where the server handles Drupal's purge:

const { createSchemaRefresh } = require('druxt-schema');

const schemas = createSchemaRefresh('https://example.com');

// In the request handler.
if (pathname.startsWith('/_druxt/schema/')) {
  req.url = pathname.slice('/_druxt/schema'.length);
  return schemas.handler(req, res);
}

// Where the server handles Drupal's purge.
schemas.clear();

Create the refresh once and keep it. A DruxtSchema instance keeps the configuration it has read for as long as it lives, so one held by your own code never shows a renamed field. The refresh starts a new instance on each clear.


API


Options

Druxt options

These options are available to all Druxt modules.

| Option | Type | Required | Default | Description | | ---------- | -------- | -------- | ---------- | ---------------------------------------------------------------------------- | | axios | object | No | {} | Axios instance settings. | | baseUrl | string | Yes | null | Base URL for the Drupal installation. | | endpoint | string | No | /jsonapi | JSON:API Endpoint of the Drupal installation. |

Druxt Schema options

These options are specific to this module.

| Option | Type | Required | Default | Description | | ---------------- | --------- | -------- | ------- | ---------------------------------------------------------------------------- | | schema.filter | array | No | [] | Array of regular expression rules to filter generated schemas. | | schema.refresh | boolean | No | false | Regenerate schemas on the Nuxt server after each cache clear, with no build. |

Links

  • DruxtJS: https://druxtjs.org
  • Documentation: https://druxtjs.org/modules/schema
  • Community Discord server: https://discord.druxtjs.org