Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Configuration Language Lock 1.0.2 Minor update available for module config_language_lock (1.0.2). Release: Canvas Override 1.0.1 Minor update available for module canvas_override (1.0.1). Release: Media Remote Image 8.x-1.2 Minor update available for module media_entity_remote_image (8.x-1.2). Release: IDNA Convert Service (punycode) 2.0.4 Minor update available for module idna (2.0.4). Release: Bootstrap Cloud 7.1.3 Minor update available for theme bootstrap_cloud (7.1.3). Release: Token Browser 1.0.2 Minor update available for module token_browser (1.0.2). Release: Varbase Project 11.0.8 Minor update available for module varbase_project (11.0.8). Release: Media Remote Image 2.0.0-beta1 First beta version released for module media_entity_remote_image (2.0.0-beta1). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Security Coverage: Module Scout Module module_scout now has official Drupal security advisory coverage.

SDX DRAST (Theme Engine)

1 sites No security coverage

Part of the SDX ecosystem · 6 projects

View on drupal.org

SDX DRAST replaces Drupal's Twig templates with a system that outputs typed JSON, allowing JavaScript frameworks like React, Vue, or Svelte to consume structured data directly. This enables dynamic rendering and region-level partial reloads for a more efficient hybrid or decoupled Drupal experience.

SDX DRAST (Drupal Render Arrays to Structured Tokens) replaces Drupal's Twig template engine with a structured data pipeline. Instead of producing HTML strings, the engine outputs typed JSON that React, Vue, or Svelte components consume directly. Write block.tsx instead of block.html.twig, and your framework component receives structured props instead of pre-rendered markup.

Why SDX DRAST

Twig produces HTML strings. JavaScript frameworks consume data. SDX DRAST bridges that gap at the Drupal render pipeline level, so your components never parse DOM or decode HTML markers.

Every rendering path (page load, SPA navigation, AJAX dialog) produces the same structured output. One pipeline, one data format.

Features

Structured Token Rendering

  • Self-contained tokens (__SDX{base64json}SDX__) embed component ID and props directly in the string
  • Tokens survive Drupal's render cache without side-channel state
  • Server resolves tokens into ComponentNode[] arrays before sending to the client
  • Client receives clean JSON. No DOM parsing, no base64 decoding, no HTML markers

Template Engine

  • Implements Drupal's template engine contract as a drop-in Twig replacement
  • Resolves .tsx, .vue, .svelte templates for any Drupal theme hook
  • Template auto-discovery: templates/block/block.tsx, templates/form-element/form-element.tsx
  • Scans themes, base themes, and enabled modules for template overrides
  • Set engine: drast in your theme's .info.yml to activate

Region-Level Partial Reloads

  • Per-region cache tag checksums computed during rendering
  • On SPA navigation, only regions whose cache tags changed are re-rendered and sent
  • Unchanged regions preserved client-side from previous navigation

AJAX Structured Responses

  • Tokens in AJAX dialog responses are resolved to structured data automatically
  • Forms opened in modals receive the same structured output as full page loads

DataProvider Plugin System (sdx_data_provider submodule)

  • Route-level typed data via PHP 8 attributes (#[SdxDataProvider])
  • Prop priorities: Prop::IMMEDIATE, Prop::DEFERRED, Prop::LAZY for progressive loading
  • Persistent layouts via getLayout() keep UI state across navigations
  • Partial prop updates, CSRF token injection, contextual links resolution
  • DataProviders included: admin overview, appearance, block layout, config pages, content types, entity lists, field UI, help, menu editor, permissions, status report, Views editor, and more

Serialization

  • Form serialization with per-element-type handlers (select, textarea, boolean, file, table, text format, etc.)
  • Entity field extraction, render array serialization, native HTML rendering for standard Drupal elements
  • Breadcrumb, tabs, actions, and messages extraction via PageDataExtractor

How It Works

Render array > Drupal renderer (structured mode) > self-contained tokens > PageRenderer resolves tokens > ComponentNode[] JSON > Client renders directly

The engine hooks into Drupal's standard rendering pipeline. When a theme hook is rendered, DrastThemeEngine creates a structured token instead of calling Twig. PageRenderer collects all tokens after the page is built, resolves them into a typed component tree, serializes regions with cache tag checksums, and sends the result as JSON.

The client framework receives a complete page description: regions as component arrays, metadata (title, breadcrumb, tabs, messages), and the main content as either a DataProvider response or resolved region data.

Post-Installation

  • Install the SDX module first
  • Enable sdx_drast and optionally sdx_data_provider
  • Set engine: sdx in your theme's .info.yml
  • Create framework templates in your theme's templates/ directory
  • Run drush cr to rebuild the theme registry

A base theme with common Drupal templates already implemented is available at SDX React Base.

Additional Requirements

  • Drupal 10.3+ or 11
  • PHP 8.3+
  • SDX module
  • A theme with engine: sdx and framework component templates
  • SDX (required) provides framework plugins, build pipeline, and component discovery
  • sdx_router (included in SDX) for SPA navigation with partial reloads
  • sdx_ssr (included in SDX) for server-side rendering of full pages
  • SDX React Base base theme with standard Drupal templates

Similar projects

Inertia.js for Laravel replaces Blade with React/Vue page components. SDX DRAST takes the same approach for Drupal but goes deeper: template-level replacement (not just page-level), region-level partial reloads via cache tags, and integration with Drupal's block and render systems.

Decoupled Drupal (Next.js, Nuxt, Gatsby) requires a separate frontend application and a JSON API layer. SDX DRAST keeps everything in Drupal: one deployment, one codebase, full access to admin UI, permissions, and editorial workflows.

Supporting this Module

Report bugs and feature requests in the issue queue.

Part of the SDX ecosystem. The engine is a separate module because it is optional: SDX components work in Twig templates without it.

Community Documentation

- Coming Soon -

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Apr 2026
Latest release
3 weeks ago
Releases (12 mo)
6 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.x-dev Dev 11 Aug 17, 2026
1.0.0-alpha6 Pre-release 10–11 Aug 17, 2026
1.0.0-alpha5 Pre-release 10–11 Aug 17, 2026
1.0.0-alpha3 Pre-release 10–11 Aug 9, 2026
1.0.0-alpha2 Pre-release 10–11 Apr 28, 2026
1.0.0-alpha1 Pre-release 10–11 Apr 23, 2026