Core API Reference
SynergyJS exposes a minimal surface area centered around define(), standard JavaScript getters for derived state, and native Custom Element lifecycle hooks.
define(tagName, factory, [options])
Registers a Custom Element with the browser's customElements registry.
tagName(string): Valid custom element name containing a hyphen (e.g."user-badge").factory(Function): Receives initial attributes and returns the reactive view-model object.options.template(HTMLTemplateElement | string): Optional template element or selector if different from#tagName.options.shadowRoot('open' | 'closed'): Optional Shadow DOM encapsulation mode.
Computed Properties
Define standard JavaScript getters on your returned object. SynergyJS automatically tracks any reactive dependencies read inside the getter:
define('cart-summary', () => ({
items: [12, 18, 25],
get total() {
return this.items.reduce((sum, n) => sum + n, 0)
}
}))
Lifecycle Hooks
Include connectedCallback() or disconnectedCallback() methods on your view-model to initialize timers, fetch initial data, or clean up subscriptions when the element enters or leaves the document.