Runtime API
This page summarizes the public runtime functions available in ZhinNX.
Routing
| API | Description |
|---|---|
createApp(target) | Mounts the app runtime. |
page(path, render) | Registers a page. |
go(path) | Navigates to another route. |
notFound(render) | Registers a fallback page. |
Events
| API | Description |
|---|---|
action(name, handler) | Registers an event handler callable from templates. |
Rendering
| API | Description |
|---|---|
each(items, render) | Maps arrays into HTML strings. |
cx(...values) | Joins class names conditionally. |
State
| API | Description |
|---|---|
state(name, initialValue) | Creates named state. |
get(path) | Reads a state value. |
set(path, value) | Writes a state value. |
update(path, callback) | Updates a value using its previous value. |
subscribe(name, handler) | Subscribes to state changes. |
Storage
| API | Description |
|---|---|
save(key, value) | Saves data to localStorage. |
load(key, fallback) | Loads data from localStorage. |
remove(key) | Removes saved data. |
UI
| API | Description |
|---|---|
toast(message) | Shows a toast. |
modal(options) | Opens a modal. |
sheet(options) | Opens a bottom sheet. |
confirm(options) | Opens a confirm dialog and resolves true or false. |
loading(message) | Shows loading feedback and returns a stop function. |
API
| API | Description |
|---|---|
api.get(url, options) | Sends GET request. |
api.post(url, body, options) | Sends POST request. |
api.put(url, body, options) | Sends PUT request. |
api.delete(url, options) | Sends DELETE request. |
FastLoad
| API | Description |
|---|---|
fastPage(path, config) | Registers a progressive FastLoad page. |
chunk(selector, render, options) | Creates a render chunk. |
lazyChunk(selector, importFn, options) | Creates a dynamically imported chunk. |
isFastPageActive() | Returns true when the current route is a FastLoad page. |
DOM patching
| API | Description |
|---|---|
patch(selector, html) | Replaces matching DOM content and re-binds ZhinNX events. |
refresh(selector, html?) | Patches when HTML is provided, or only re-binds events when omitted. |