Skip to content

MIDDAG React UIContract-driven components for Moodle & WordPress

The backend sends a PageContract JSON object. The frontend renders it. No manual wiring needed.

Quick Overview

ts
import { ContractPage, registerDefaults } from '@middag-io/react';
import '@middag-io/react/style.css';

// Register all built-in shells, layouts, and blocks
registerDefaults();

// Render a page from a contract
<ContractPage contract={contract} />

The rendering pipeline:

Backend (PHP)  -->  Inertia  -->  ContractPage  -->  Shell  -->  Layout  -->  Blocks

Architecture

LayerDescription
ShellOutermost wrapper (sidebar, header, navigation)
LayoutRegion arrangement inside the shell (stack, split, dashboard, etc.)
BlockAtomic rendering unit placed in a layout region
ProviderReact context bridges for i18n, auth, flash, scope, progress

Install

bash
# Recommended — wizard auto-detects your host and scaffolds ui/
npx create-middag-ui

# Then:
cd ui && npm install && npm run dev:mock

Or install manually: npm install @middag-io/react (see Getting Started for auth setup).

CLI

CommandDescription
npx create-middag-uiBootstrap ui/ with mock build for your host
npx @middag-io/react doctorValidate consumer project setup
npx @middag-io/react devStart mock dev server
npx @middag-io/react add-block <type>Scaffold a new block type
npx @middag-io/react upgradeCheck for updates and run codemods

See CLI Reference for details.

Released under the proprietary license.