Write once, compile to React, Vue, Svelte, SolidJS, or Pure HTML/JS
MTM is a revolutionary meta-framework that allows you to write components using a unified syntax and compile them to multiple target frameworks. The pure HTML/JS compilation works like a merge between PHP and Next.js - no framework dependencies needed!
- ๐ฏ Write Once, Run Anywhere: Single MTM syntax compiles to multiple frameworks
- ๐ Pure HTML/JS Mode: Works like PHP + Next.js with no framework dependencies
- โก Reactive Variables: Simple
$variable!
syntax for reactive state - ๐ Cross-Framework Signals: Share state between different framework components
- ๐ฆ Zero Configuration: Framework detection by filename
- ๐ก๏ธ Type Safe: Full TypeScript support with automatic inference
- ๐จ Modern Syntax: Clean, readable, and intuitive
# Clone the repository
git clone https://github.com/mtm-framework/mtm
cd mtm
# Install dependencies
npm install
Create a file called counter.mtm
:
// counter.mtm - Pure HTML/JS version
export default function Counter() {
// Reactive variables
$count! = 0
// Event handlers
$increment = () => {
$count++
}
$decrement = () => {
$count--
}
<template>
<div class="counter">
<h3>Simple Counter</h3>
<div class="counter-display">
<button click={$decrement}>-</button>
<span class="count">{$count}</span>
<button click={$increment}>+</button>
</div>
<p>This works like PHP + Next.js - pure HTML/JS!</p>
</div>
</template>
}
# Compile to pure HTML/JS
node src/mtm-compiler/final-compiler.js counter.mtm
# Open the compiled HTML file in your browser
open compiled/counter.html
mtm-framework/
โโโ src/
โ โโโ mtm-compiler/
โ โโโ final-compiler.js # Working MTM compiler
โ โโโ parser.js # MTM syntax parser
โ โโโ html-generator.js # Pure HTML/JS generator
โ โโโ cli.js # Command line interface
โโโ examples/
โ โโโ mtm-components/ # MTM source files
โ โ โโโ simple-counter.mtm # Working counter example
โ โ โโโ counter.react.mtm # React version (planned)
โ โ โโโ counter.vue.mtm # Vue version (planned)
โ โ โโโ form.mtm # Form example (planned)
โ โโโ serve-compiled.js # Development server
โโโ compiled/ # Compiled output files
โโโ README.md
counter.mtm; // โ Pure HTML/JS
counter.react.mtm; // โ React component
counter.vue.mtm; // โ Vue component
counter.svelte.mtm; // โ Svelte component
counter.solid.mtm; // โ SolidJS component
// Reactive variables (trigger UI updates)
$count! = 0
$message! = "Hello"
$items! = []
// Computed variables (derived from reactive variables)
$doubleCount = $count * 2
$greeting = `Hello, ${$message}!`
// Event handlers
$increment = () => {
$count++;
};
// Async functions
$fetchData = async () => {
$loading = true;
$data = await fetch("/api/data").then((r) => r.json());
$loading = false;
};
<template>
<!-- Variable interpolation -->
<span>{$count}</span>
<span>{$message}</span>
<!-- Event handlers -->
<button click="{$increment}">Click me</button>
<!-- Conditional rendering -->
{#if $count > 5}
<div>Count is high!</div>
{/if}
<!-- List rendering -->
{#each $items as item}
<div>{item.name}</div>
{/each}
</template>
Framework | Status | Description |
---|---|---|
Pure HTML/JS | โ Working | Complete HTML files with embedded reactive JavaScript |
React | ๐ง Planned | JSX with hooks (useState, useCallback) |
Vue | ๐ง Planned | Vue 3 composition API with reactive refs |
Svelte | ๐ง Planned | Svelte syntax with reactive statements |
SolidJS | ๐ง Planned | SolidJS components with createSignal |
MTM Input:
// counter.mtm
export default function Counter() {
$count! = 0
$increment = () => {
$count++
}
<template>
<div class="counter">
<button click={$increment}>Count: {$count}</button>
</div>
</template>
}
Pure HTML/JS Output:
<!DOCTYPE html>
<html>
<head>
<title>Counter</title>
<style>
/* Beautiful CSS styles */
</style>
</head>
<body>
<div id="app">
<div class="counter">
<button data-click="$increment">
Count: <span data-bind="$count">0</span>
</button>
</div>
</div>
<script>
// Reactive system
const reactive = (initialValue) => {
let value = initialValue;
const subscribers = [];
return {
get value() {
return value;
},
set value(newValue) {
value = newValue;
subscribers.forEach((fn) => fn(newValue));
},
subscribe(fn) {
subscribers.push(fn);
},
};
};
// Component
function Counter() {
const $count = reactive(0);
const $increment = () => {
$count.value++;
};
// DOM bindings
const container = document.getElementById("app");
container.querySelectorAll('[data-bind="$count"]').forEach((el) => {
const update = () => (el.textContent = $count.value);
update();
$count.subscribe(update);
});
container
.querySelectorAll('[data-click="$increment"]')
.forEach((el) => {
el.addEventListener("click", $increment);
});
}
document.addEventListener("DOMContentLoaded", () => {
Counter();
});
</script>
</body>
</html>
- Framework Lock-in: Choose React, Vue, or Svelte and you're stuck
- Code Duplication: Same logic written multiple times for different frameworks
- Learning Curve: Each framework has different syntax and patterns
- Bundle Size: Framework overhead even for simple components
- โ Write Once: Single MTM syntax for all frameworks
- โ No Lock-in: Compile to any framework or pure HTML/JS
- โ PHP + Next.js Style: Pure HTML/JS works without any framework
- โ Modern Syntax: Clean, readable, and intuitive
- โ Zero Overhead: Pure HTML/JS has no framework bundle
- โ Cross-Framework: Share state between different framework components
Feature | MTM | Astro | Qwik | Lit |
---|---|---|---|---|
Pure HTML/JS Output | โ | โ | โ | โ |
Multi-Framework | โ | โ | โ | โ |
PHP-like Simplicity | โ | โ | โ | โ |
Zero Dependencies | โ | โ | โ | โ |
Reactive Variables | โ | โ | โ | โ |
Cross-Framework Signals | โ | โ | โ | โ |
# Compile the simple counter
node src/mtm-compiler/final-compiler.js examples/mtm-components/simple-counter.mtm
# Open in browser
open compiled/simple-counter.html
# Create a new MTM file
echo 'export default function MyComponent() {
$message! = "Hello MTM!"
<template>
<div>
<h1>{$message}</h1>
<p>This works like PHP + Next.js!</p>
</div>
</template>
}' > my-component.mtm
# Compile it
node src/mtm-compiler/final-compiler.js my-component.mtm
# Open the result
open compiled/my-component.html
# Install dependencies
npm install
# Start the server
npm run serve-examples
# Open http://localhost:3000
npm test
# Compile all examples
node compile-all-examples.js
# Compile specific file
node test-compiler.js
- Create a new generator in
src/mtm-compiler/
- Add framework detection logic
- Implement the compilation pipeline
- Add tests and examples
- MTM syntax parser
- Pure HTML/JS compiler
- Basic reactive system
- Working examples
- React generator
- Vue generator
- Svelte generator
- SolidJS generator
- TypeScript support
- CSS preprocessing
- Component composition
- Server-side rendering
- Build optimizations
- VS Code extension
- CLI improvements
- Hot reloading
- Error reporting
- Documentation site
We welcome contributions! Here's how you can help:
- Try MTM: Use it in your projects and report issues
- Add Framework Support: Implement generators for React, Vue, etc.
- Improve Parser: Add support for more MTM syntax features
- Write Examples: Create more MTM component examples
- Documentation: Help improve docs and guides
git clone https://github.com/mtm-framework/mtm
cd mtm
npm install
npm test
MIT License - see LICENSE for details.
- Inspired by the simplicity of PHP and the power of Next.js
- Built with modern JavaScript and a focus on developer experience
- Thanks to all the framework creators who inspired this meta-framework approach
MTM Framework - Write once, compile anywhere! ๐ฎ
The future of meta-framework development is here. No more framework lock-in, no more code duplication, just pure simplicity that works like PHP + Next.js.