---
title: "MIDDAG React UI"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.middag.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MIDDAG React UI

**Contract-driven components for Moodle & WordPress**

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

- [Get Started](/middag-react/latest/getting-started)
- [Live Demo](https://ui-demo.middag.io)
- [API Reference](/middag-react/latest/reference/api)

- **Contract-Driven**: The backend builds a PageContract describing shell, layout, and blocks. The frontend resolves each piece through registries and renders the full page automatically.
- **Host-Agnostic**: Works with Moodle, WordPress, or any Inertia.js host. The host adapter system handles chrome, i18n, and theme detection transparently.
- **Block Catalog**: From dense tables and form panels to flow editors and sentence builders. Every block is data-driven with a typed contract.
- **Dark Mode & RTL**: Three-tier theme resolution (manual, host, OS) with full right-to-left support. OKLCH color system for perceptual uniformity.
- **Type-Safe**: Full TypeScript types for PageContract, BlockDescriptor, NavigationNode, SharedProps, and all block data interfaces.
- **Extensible**: Register custom shells, layouts, and blocks. Override built-in components. Compose providers for auth, i18n, flash, scope, and progress.

## 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

| Layer        | Description                                                             |
|--------------|-------------------------------------------------------------------------|
| **Shell**    | Outermost wrapper (sidebar, header, navigation)                         |
| **Layout**   | Region arrangement inside the shell (stack, sidebar, dashboard, wizard) |
| **Block**    | Atomic rendering unit placed in a layout region                         |
| **Provider** | React context bridges for i18n, auth, flash, scope, progress            |

## Install

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

# PRO — source maps, mock SPA, full exports
npx @middag-io/create-middag-ui

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

Or install manually: `npm install @middag-io/react` (see [Getting Started](/middag-react/latest/getting-started#manual-install) for auth setup).

## CLI

| Command                                 | Description                        |
|-----------------------------------------|------------------------------------|
| `npx create-middag-ui`                  | Bootstrap `ui/` (Community)        |
| `npx @middag-io/create-middag-ui`       | Bootstrap `ui/` (PRO)              |
| `npx @middag-io/react doctor`           | Validate consumer project setup    |
| `npx @middag-io/react dev`              | Start mock dev server              |
| `npx @middag-io/react add-block <type>` | Scaffold a new block type          |
| `npx @middag-io/react upgrade`          | Check for updates and run codemods |

See [CLI Reference](/middag-react/latest/cli) for details.

Source: https://docs.middag.dev/middag-react/latest/index.mdx
