Regor is a runtime-first UI framework for teams that want direct DOM control, strong TypeScript ergonomics, and precise reactivity behavior without being forced into a Virtual DOM architecture.
Its template syntax is familiar to Vue users (r-if, r-model, r-for, r-bind), but its runtime model is intentionally different: Regor is built for progressive enhancement, mixed-rendering environments, and incremental adoption.
- No VDOM Layer: Bind directly to real DOM for transparent runtime behavior and straightforward debugging.
- TypeScript-Native: Use standard TypeScript interfaces, classes, and generics without framework-specific file formats.
- No Build Step Required: Define components in TypeScript using tagged string templates with npm, CDN ESM, or global build workflows.
- Secure Evaluation: Regor's secure JavaScript VM ensures safe runtime compilation. You can enable security policy in your page without removing runtime compilation support.
<meta
http-equiv="Content-Security-Policy"
content="require-trusted-types-for 'script';"
/>- Flexible Reactivity: Combine
ref,sref,batch,pause,resume, andentanglefor explicit state orchestration. - Static-First + Islands: Bind to existing DOM without removing server-rendered HTML, ideal for progressive enhancement.
- Reentrance: Mount multiple times in already-mounted regions with same or different app contexts.
- Compatibility: Rendered pages are designed for seamless integration with other libraries manipulating the DOM.
Discover the capabilities of Regor by diving into our comprehensive documentation. Whether you're new to Regor or an experienced user, our documentation provides in-depth insights into its features, API, directives, and more.
Start exploring the Regor Documentation now to harness the full potential of this powerful UI framework. The documentation sources are located in docs-site.
Regor is developed using Node.js 18 and Yarn. Ensure you have Node.js 18 or newer installed before running the examples or the documentation site.
Click and count sample source:
import { createApp, ref } from 'regor'
createApp({
count: ref(0),
})HTML:
<div id="app">
<button @click="count++">Count is: {{ count }}</button>
</div>Defining component:
import { createApp, createComponent, ref, html, type Ref } from 'regor'
interface MyComponent {
message: Ref<string>
}
const template = html`<button @click="count++">
{{ message }} {{ count }}
</button>`
const props = ['message']
const myComponent = createComponent<MyComponent>(template, {
context: (head) => ({
message: head.props.message,
count: ref(0),
}),
props,
})
createApp({
components: { myComponent },
message: ref('Count is:'),
})HTML:
<div id="app">
<MyComponent :message="message"></MyComponent>
<my-component :message="message"></my-component>
</div>Regor preprocesses table-related templates to keep markup valid when using components in table structures.
- Supported table containers:
table,thead,tbody,tfoot. - Component tags directly under row containers are normalized to valid hosts.
- Component tags directly under
<tr>are normalized to<td>hosts (except native<td>/<th>). - Regor preserves valid table markup while supporting component-based rows and cells in table templates.
Example:
<table>
<tbody>
<TableRow r-for="row in rows" :row="row" />
</tbody>
</table>const tableRow = createComponent(
html`<tr>
<TableCell :value="row.name" />
<TableCell :value="row.age" />
</tr>`,
{ props: ['row'] },
)Define composables:
import { ref, onMounted, onUnmounted, type Ref } from 'regor'
export const useMouse = (): { x: Ref<number>; y: Ref<number> } => {
const x = ref(0)
const y = ref(0)
const update = (event: MouseEvent): void => {
x(event.pageX)
y(event.pageY)
}
onMounted(() => window.addEventListener('mousemove', update))
onUnmounted(() => window.removeEventListener('mousemove', update))
return { x, y }
}yarn add regor
or
npm install regor
Regor is openly inspired by Vue’s concepts (even adopting a similar directive syntax like r-if / r-model instead of v-if / v-model), but it fundamentally diverges in its implementation. It prioritizes runtime flexibility, build-less environments, and strict TypeScript integration over the Virtual DOM (VDOM) paradigm.
- Vue: Uses a Virtual DOM. This provides excellent performance for highly dynamic Single Page Applications (SPAs) because Vue calculates diffs in memory before updating the browser. However, it usually requires a compilation step to optimize templates, and hydrating existing server-rendered HTML can be notoriously strict (hydration mismatches).
- Regor: Ditches the VDOM entirely. It binds directly to the actual DOM. Regor explicitly supports Static-first + dynamic islands and "Reentrance." You can mount an application multiple times over already-mounted regions or existing server-rendered HTML without destroying the elements.
- Verdict: Regor is significantly more flexible for integrating into existing applications, multi-page applications (MPAs), or legacy backends.
- Vue: Commonly paired with a build pipeline for SFCs and tooling depth.
- Regor: Designed to require no build step. You can write standard TypeScript using tagged string templates (e.g.,
htmltags for templates) and it will evaluate at runtime. Crucially, Regor features a Secure JavaScript VM for runtime compilation that adheres to strict Content Security Policies (CSP)—a common pain point when using Vue's runtime compiler in enterprise environments. - Verdict: Regor wins in deployment flexibility and zero-config setups. It respects modern security policies out of the box without demanding a bundler.
- Vue: Uses ES6 Proxies for a highly automated, "magical" reactivity system. You update an object, and Vue figures out what to re-render. However, this magic can sometimes abstract away performance bottlenecks, leading to over-rendering if you aren't careful with deep reactivity.
- Regor: Provides fine-tuned, manual control. It offers
ref(deep reactivity) andsref(simple/shallow reactivity without nested observation). Furthermore, Regor provides advanced control APIs likepause()andresume()to stop a ref's auto-triggers,entangle()to sync two refs effortlessly, andbatch()for precise state grouping. - Verdict: Vue's reactivity is easier for beginners.. Regor’s reactivity is more flexible and transparent, giving engineers exact tools to orchestrate update semantics and prevent unwanted DOM paints.
- Vue: TypeScript support in Vue has improved massively, but it still relies on heavy IDE plugins (Volar) and specialized compilers (vue-tsc) to understand .vue files. The separation between the
<template>and<script>requires tooling to bridge the gap. - Regor: Offers native TypeScript support without workarounds. Because components and templates are defined using standard TypeScript functions, class-based contexts, and
ComponentHead<T>, standard TypeScript compilers and IDEs understand 100% of the code immediately. - Verdict: Regor offers a purer, higher-quality TypeScript experience. It leverages the language itself rather than relying on framework-specific compiler magic to provide type safety.
Regor provides a set of directives that allow you to enhance the behavior and appearance of your applications. Similar to Vue's directives, Regor's directives start with the "r-" prefix.
Note: The directive prefix "r-" can be customized using
RegorConfig.getDefault().setDirectives('v-')to align with a different naming convention, such as Vue's "v-" prefix.
r-bindBinds an element's attribute to a component's data, allowing dynamic updates.r-modelEnables two-way data binding between form inputs.r-textSets the element's text content to the result of an expression.r-htmlRenders the result of an expression as HTML content within the element.r-onAttaches event listeners to the element and invokes specified component methods.r-showConditionally displays the element based on the truthiness of an expression.r-forRenders a set of elements based on an array and a template.r-ifConditionally renders the element based on the truthiness of an expression.r-elseProvides an alternative rendering when used in conjunction with r-if.r-else-ifConditionally renders the element as an alternative to r-if.r-preExcludes HTML element from Regor bindings.:classBinds one or more class names to an element based on expressions.:styleBinds one or more inline styles to an element based on expressions.:refProvides a reference to an element in the template, allowing you to interact with it programmatically.:keyProvides a unique identifier for each item in a list, aiding efficient updates and rendering.:isSpecifies the component to dynamically render based on a value or expression.r-teleportTeleports the element to anywhere in the DOM. Unlike Vue, teleport is a directive to avoid component overhead.:propsVue uses v-bind for component property passing. However, this can conflict with v-bind's attribute fall-through logic. Hence, Regor defines a dedicated directive to pass properties using object syntax. It enables passing properties without defining them in the component's props contract.:props-onceSimilar to :props but it doesn't observe entire reactive tree of the template expression. Tail reactivity still works.@Shorthand forr-onto bind event listeners.:Shorthand forr-bindto bind element attributes..Shorthand forr-bind.propto set properties.
These directives empower you to create dynamic and interactive user interfaces, enhancing the user experience of your Regor-powered applications.
App / Component Template Functions
createAppSimilar to Vue'screateApp, it initializes a Regor application instance.createComponentCreates a Regor component instance.toFragmentConverts a JSON template to a document fragment.toJsonTemplateConverts a DOM element to a JSON template.
Cleanup Functions
addUnbinderAdds an unbinder to a DOM element.getBindDataRetrieves bind data associated with a DOM element.removeNodeRemoves a node while properly disposing of associated bind data and observers.unbindUnbinds a node, disposing of observers and bind data.
Compute Functions
computedSimilar to Vue'scomputed, it creates a computed property.computedComputes the value observing a single ref, more efficient than observing any.computeManyComputes the value observing given refs, more efficient than observing any.watchEffectSimilar to Vue'swatchEffect, it watches for reactive changes.collectRefsLikewatchEffect, but runs once and returns all refs used in the evaluated action.silenceSilences the ref collection in awatchEffectorcollectRefs.
Misc Functions
flattenFlattens a given ref object into a raw object recursively.isRawChecks if a given ref is marked as raw.markRawMarks a ref as raw.persistPersists a given ref in local storage reactively.htmlA tag to produce HTML string using template literals. Recommended to use with the VS-Codelit-htmlextension for formatting and highlighting.rawA tag to produce HTML string, similar tohtml, but it is excluded from formatting whenlit-htmlextension is installed.
Observe Functions
observeObserves changes in a single ref.observeManyObserves changes in multiple refs.observerCountRetrieves the active observer count of a ref.batchPerforms batch updates, triggering changes at the end. Use with caution due to possible dirty reads.startBatchStarts a batch update.endBatchEnds a started batch update and triggers affected refs.
Reactivity Functions
refCreates a deep ref object recursively, modifying the source object in place.srefCreates a simple ref object from a given value, without nested ref creation.isDeepRefReturns true if a given ref is created withref()function.isRefReturns true for any ref, false for non-refs.pausePauses a ref's auto-trigger on value change.resumeResumes a ref's auto-trigger on value change.triggerManually triggers a ref to inform its observers.unrefUnwraps a ref, returning the raw value.entangleEntangles two refs to sync their value changes.
Composition Functions
useScopeIn a scope, you can useonMountedandonUnmountedfunctions. Components are always created in scope. Use the useScope for apps created by createApp. Similar to Vue'seffectScope, useScope provides efficient cleanup of watchEffects, computed refs, observers and enables theonMountedandonUnmountedcalls in the scope.onMountedSimilar to Vue'sonMounted, it executes when the component is mounted.onUnmountedSimilar to Vue'sonUnmounted, it executes when the component is unmounted.
Log Configuration
warningHandlerCustomize or turn off console warnings.
This project welcomes contributions and suggestions. Please follow CONTRIBUTING.md instructions.
Regor is built upon the shoulders of giants, drawing inspiration from Vue and its vibrant community of contributors. The well-defined concepts and principles from Vue have played a pivotal role in shaping Regor's foundation. We extend our heartfelt gratitude to the Vue project and its dedicated contributors for their pioneering work in the realm of UI frameworks.
Special thanks to the Vue team and its community for creating a thriving ecosystem that continues to inspire innovation in the field of web development.
Regor also utilizes Jsep, a fast and lightweight JavaScript expression parser. Jsep's contribution to Regor's functionality is greatly appreciated.
We also extend a warm welcome to any future contributors who join the Regor project. Your contributions will play a vital role in shaping the framework's growth and evolution.
Thank you to everyone who has contributed, inspired, and supported Regor's development journey. Your dedication and passion are invaluable.
