Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

JS Component

354 sites No security coverage
View on drupal.org

This module allows developers to easily integrate JavaScript or React components into Drupal. You can define these components using plugin definitions or by creating YAML files, enabling the collection of settings from site builders to be passed to the components.

Description

The module provides a streamlined solution for adding simple React or JS based components to the Drupal ecosystem. The module is more developer centric, as it allows developers to define JS components by exposing a plugin or by placing a YAML file within the module or theme directory.

The libraries directive follows the same syntax as what you would expect in a *.libraries.yml. The settings directive allows you to collect information from the site-builder. It follows the same structure as the Drupal form API. Inputted settings are exposed to the JS component using the drupalSettings concept.

Below is an example of what a JS component YAML base definition looks like.

[THEME/MODULE].js_component.yml

component_1:
  label: My React Component
  description: This app will run the world!
  root_id: root
  libraries:
    js:
      /js_component/react-app/build/static/js/main.ca4c6d6d.js: {}
    css:
      theme:
        /js_component/react-app/build/static/css/main.666d445f.css: {}
  settings:
    collect_user_input:
      type: 'select'
      title: 'User Input'
      description: 'Any data you would like to provide to the react application.'
      options:
        option-1: Option 1
        option-2: Option 2
      empty_option: '- Select -'

If you need to encapsulate a component as a twig template file. Which then you can define the following in the JS component definition:

component_2:
  label: Twig Template
  description: The basic twig template example.
  template: js_component/custom/twig-template.html.twig
  libraries:
    css:
      theme:
        /js_component/custom/main.css: {}
  settings:
    header_title:
      type: textfield
      title: Header Title
      description: Input JS component header title.

Activity

Total releases
1
First release
Jan 2026
Latest release
6 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
2.0.0-alpha3 Pre-release Jan 15, 2026