# @memberjunction/react-runtime
Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, dynamic library management, and execution capabilities for React components in any JavaScript environment.
## Architecture
```mermaid
graph TD
subgraph "@memberjunction/react-runtime"
A[createReactRuntime] --> B[ComponentCompiler]
A --> C[ComponentRegistry]
A --> D[ComponentResolver]
A --> E[ComponentManager]
B --> F["Babel Standalone
(JSX Compilation)"]
C --> G[Component Store]
C --> H[Namespace Support]
D --> I[Component Resolution]
D --> J[Dependency Resolution]
E --> K[Load + Compile + Register]
subgraph "Utilities"
L[LibraryLoader]
M[LibraryRegistry]
N[CacheManager]
O[ResourceManager]
P[ErrorBoundary]
Q[PropBuilder]
R[ReactRootManager]
end
end
subgraph "Runtime APIs"
S[ComponentHierarchyRegistrar]
T[StandardLibraries]
U[ComponentErrorAnalyzer]
end
style A fill:#2d6a9f,stroke:#1a4971,color:#fff
style B fill:#2d8659,stroke:#1a5c3a,color:#fff
style C fill:#2d8659,stroke:#1a5c3a,color:#fff
style D fill:#7c5295,stroke:#563a6b,color:#fff
style E fill:#7c5295,stroke:#563a6b,color:#fff
style L fill:#b8762f,stroke:#8a5722,color:#fff
style N fill:#b8762f,stroke:#8a5722,color:#fff
style P fill:#b8762f,stroke:#8a5722,color:#fff
```
## Overview
This package enables dynamic compilation and execution of React components at runtime. Components can be loaded from MemberJunction's database, compiled with Babel, registered into a component registry, and rendered with full dependency resolution.
**Key capabilities:**
- **Component Compilation**: Transpiles JSX/TSX source code using Babel standalone
- **Component Registry**: LRU-cached registry with namespace support for up to 1000 components
- **Component Resolution**: Resolves component specs against the registry with dependency tracking
- **Component Manager**: Unified API for loading, compiling, and registering components in one call
- **Library Management**: Dynamic library loading, registration, and dependency resolution
- **Error Boundaries**: Configurable error boundary creation with logging
- **Prop Building**: Type-safe prop construction with callback normalization and style processing
- **React Root Management**: Managed React root lifecycle for mounting/unmounting components
- **Caching**: LRU cache with configurable TTL for compiled components
- **UMD Build**: Ships both CommonJS and UMD bundles for browser environments
## Installation
```bash
npm install @memberjunction/react-runtime
```
## Usage
### Quick Start
```typescript
import { createReactRuntime } from '@memberjunction/react-runtime';
import * as Babel from '@babel/standalone';
const runtime = createReactRuntime(Babel, {
compiler: { minify: false, sourceMaps: true, cache: true },
registry: { maxComponents: 500 }
});
// Compile a component from source
const compiled = runtime.compiler.compile(`
function MyComponent({ name }) {
return