Skip to content

mount

Render a DOM tree into a real DOM element.

/**
* Render a DOM node to the DOM.
* @param vNode Node or function returning one.
* @param rootSelector CSS selector for the root element, defaults to #app.
*/
mount(vNode: VNode | (() => VNode), rootSelector?: string): void

Mount a DOM tree to a real DOM node. Use with signal for reactivity.

import { signal } from '@hellajs/core';
import { mount, html } from '@hellajs/dom';
const { div, h1, button } = html;
const count = signal(0);
const increment = () => {
count(count() + 1);
};
const App = () => {
return (
<div>
<h1>Count: {count()}</h1>
<button onClick={increment}>Increment</button>
</div>
);
};
// Mount the App
mount(App, '#root');