API Reference
Every export from glyx (@glyx-dev/react). React hooks and standard library — import those from 'react' directly.
Core components
| Export | Props summary |
|---|---|
View | style, width, height, layout props, glyxDraggable, _glyxOnMount |
Text | style, numberOfLines, ellipsizeMode, selectable, onPress |
Pressable | onPress, onPressIn, onPressOut, onLongPress, onHoverIn, onHoverOut, onRightPress, disabled, style (static or (state) => style) |
TextInput | value, onChangeText, placeholder, secureTextEntry, multiline, style, ref |
ScrollView | style, onScroll, horizontal, bounces |
Image | src, width, height, resizeMode ('cover'|'contain'|'stretch'|'center') |
RepaintBoundary | style, children — caches subtree as a GPU layer |
VirtualizedList | data, renderItem, itemHeight, style |
Canvas | style, ref — 2D drawing surface |
Canvas3D | style, ref — wgpu 3D surface |
WindowControls | style — platform-native min/max/close buttons |
Camera | mirror, style, ref |
Video | src, style, ref, autoPlay, loop, muted |
Form components
| Export | Key props |
|---|---|
Select | value, onValueChange, options: {label,value}[], placeholder, disabled |
DatePicker | value: Date|string|null, onValueChange, disabled |
TimePicker | value: 'HH:MM'|null, onValueChange, use24Hour, minuteStep |
DateTimePicker | value: Date|string|null, onValueChange, use24Hour, minuteStep |
Checkbox | checked, onChange, disabled, label |
Switch | value, onValueChange, disabled |
RadioGroup | value, onValueChange, children |
Radio | value, label, disabled — must be inside RadioGroup |
Slider | value, onValueChange, min, max, step, disabled |
FileInput | onFilesSelected, accept, multiple, label, disabled |
Hooks
import { useWindowSize, useScreenSize, useMediaQuery, useDraggable } from '@glyx-dev/react'| Hook | Returns | Description |
|---|---|---|
useWindowSize() | { width, height } | Current window size in logical pixels; updates on resize |
useScreenSize() | { width, height } | Primary monitor resolution |
useMediaQuery(minWidth) | boolean | true when window width ≥ minWidth |
useDraggable(handlers) | event handler props | Attach to any View for custom drag interactions |
useDraggable handlers
useDraggable({
onDragStart?: (x: number, y: number) => void
onDragMove?: (dx: number, dy: number) => void
onDragEnd?: (x: number, y: number) => void
})Overlay / Popover
import { openPopover, closePopover } from '@glyx-dev/react'| Export | Signature | Description |
|---|---|---|
openPopover | (opts) → id: number | Open a floating layer anchored to an element |
closePopover | (id: number) → void | Close a specific popover |
PopoverHost | component | Auto-injected by render() — do not mount manually |
openPopover options: x, y, h, width, contentH, render: () => ReactElement, onClose: () => void.
See Popover for full docs.
App lifecycle
import { render, getEnv, measureText } from '@glyx-dev/react'| Export | Signature | Description |
|---|---|---|
render | (element: ReactElement) → void | Mount the root element. Call once at startup. |
getEnv | (name: string) → string | undefined | Read an env var injected at build time |
measureText | (text, fontSize?, maxWidth?) → {width, height} | Measure text before rendering |
glyxWindow
import { glyxWindow } from '@glyx-dev/react'Window state
| Method | Returns | Description |
|---|---|---|
setFullscreen(bool) | void | Enter / exit fullscreen |
setMaximized(bool) | void | Maximize / restore |
setMinimized() | void | Minimize to taskbar |
isFullscreen() | boolean | Current fullscreen state |
isMaximized() | boolean | Current maximized state |
getWindowSize() | {width, height} | Window size in physical pixels |
getScreenSize() | {width, height} | Primary monitor resolution |
Window properties
| Method | Returns | Description |
|---|---|---|
setTitle(title) | void | Change the title bar text |
setAlwaysOnTop(bool) | void | Pin window above others |
platform() | 'windows'|'macos'|'linux' | Host OS (cached) |
Lifecycle
| Method | Returns | Description |
|---|---|---|
close() | void | Close this window |
quit() | void | Exit the entire app |
restart() | void | Quit and re-launch |
hideSplash() | void | Hide the splash screen |
Utilities
| Method | Returns | Description |
|---|---|---|
openExternal(url) | void | Open URL / mailto in system browser |
collectMemory() | void | Trigger GC + return freed pages to OS |
create(opts?) | Promise<{id, send}> | Open a secondary window |
Network
import { fetch, Headers, ws, mdns } from '@glyx-dev/react'
// fetch and Headers are also available as globalsRequires capability: "network"
fetch
fetch(url: string, options?: {
method?: string
headers?: Headers | Record<string, string> | [string, string][]
body?: string | object // objects are JSON-serialized automatically
multipart?: MultipartPart[]
}): Promise<Response>Response properties: status, ok, statusText, url, redirected, type, bodyUsed, headers: Headers.
Response methods: text(), json(), arrayBuffer(), blob(), clone().
Headers
const h = new Headers()
h.set('Content-Type', 'application/json')
h.append('X-Custom', 'value')
h.get('content-type') // case-insensitive
h.has('x-custom')
h.forEach((value, name) => { ... })ws
ws.connect(url: string, handlers?: {
onmessage?: (ev: { data: string }) => void
onclose?: () => void
onerror?: (err: string) => void
}): Promise<{ id: number, send(msg: string): void, close(): void }>mdns
mdns.discover(serviceType: string, opts?: { timeout?: number }): Promise<MdnsService[]>
type MdnsService = { name: string, hostname: string, port: number, addresses: string[] }File system
import { fs } from '@glyx-dev/react'Requires capability: "fs"
| Method | Returns | Description |
|---|---|---|
fs.readText(path) | Promise<string> | Read file as UTF-8 text. ~ expands to home dir. |
fs.writeText(path, text) | Promise<void> | Write UTF-8 text, creating parent dirs |
fs.readDir(path) | Promise<DirEntry[]> | List directory. DirEntry: {name, isDir, size} |
fs.readFileBytes(path) | Promise<string> | Read file as base64 |
fs.exists(path) | Promise<boolean> | Check if path exists |
fs.delete(path) | Promise<void> | Delete file or empty directory |
fs.createDir(path) | Promise<void> | Create directory (and parents) |
fs.move(from, to) | Promise<void> | Move / rename |
Database
import { db } from '@glyx-dev/react'Requires capability: "db"
| Method | Returns | Description |
|---|---|---|
db.open(filename) | Promise<void> | Open (or create) a SQLite database in the app data dir |
db.close() | Promise<void> | Close the current database |
db.query(sql, params?) | Promise<Row[]> | Run a SELECT, returns array of row objects |
db.execute(sql, params?) | Promise<{changes}> | Run INSERT / UPDATE / DELETE |
db.transaction(fn) | Promise<void> | Run fn inside a transaction; auto-rollback on throw |
db.migrate(migrations[]) | Promise<void> | Apply versioned migrations in order |
Vector database
import { vectorDb } from '@glyx-dev/react'Requires capability: "vectorDb"
| Method | Returns | Description |
|---|---|---|
vectorDb.upsert(id, vector, metadata?) | Promise<void> | Insert or update a vector |
vectorDb.search(vector, topK?) | Promise<Result[]> | Find nearest neighbours |
vectorDb.delete(id) | Promise<void> | Remove a vector |
vectorDb.close() | Promise<void> | Release resources |
Dialog
import { dialog } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
dialog.openFile(opts?) | Promise<string|null> | File picker. Returns absolute path or null |
dialog.openFiles(opts?) | Promise<string[]> | Multi-file picker |
dialog.openFolder(opts?) | Promise<string|null> | Folder picker |
dialog.saveFile(opts?) | Promise<string|null> | Save-as picker |
dialog.message(text, opts?) | Promise<void> | Native alert dialog |
dialog.confirm(text, opts?) | Promise<boolean> | Native yes/no dialog |
opts for file pickers: { filters?: [{name, extensions[]}], defaultPath? }
Clipboard
import { clipboard } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
clipboard.readText() | Promise<string> | Read text from clipboard |
clipboard.writeText(text) | Promise<void> | Write text to clipboard |
Notifications
import { notification } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
notification.send(opts) | Promise<void> | Show a desktop notification |
opts: { title: string, body?: string, icon?: string }
System Tray
import { tray } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
tray.create(rgba, w, h, tooltip, menu?) | number | Create a tray icon. Returns handle ID (0 on failure). |
tray.destroy(id) | boolean | Remove a tray icon. |
tray.updateMenu(id, menu) | boolean | Replace the tray context menu. |
tray.setTooltip(id, tooltip) | void | Update the tooltip text. |
tray.pollEvents() | string | Poll pending events (call each frame). Returns JSON array. |
Menu items: { id: string, label: string, enabled?: boolean, checked?: boolean, separator?: boolean, children?: TrayMenuItem[] }
Events (returned as JSON from pollEvents()): Click | DoubleClick | MenuItemClick { tray_id, item_id }
Requires tray: true capability in glyx.config.json.
Audio
import { audio } from '@glyx-dev/react'Requires capability: "audio"
audio.play(src, opts?) starts playback and returns a player handle used for all subsequent control.
| Method | Returns | Description |
|---|---|---|
audio.play(src, opts?) | Promise<PlayerHandle> | Start playback of a file (MP3/FLAC/OGG/WAV); returns a handle |
handle.pause() / handle.resume() / handle.play() | void | Control playback |
handle.stop() | void | Stop and release the sink |
handle.seek(secs) | Promise<void> | Seek to position in seconds |
handle.setVolume(0–1) / handle.getVolume() | void / number | Volume control |
handle.getTime() | number | Current position in seconds |
handle.getDuration() | Promise<number> | Total duration (-1 if unknown) |
handle.onEnded(cb) | void | Fires when playback finishes naturally |
See the Audio page for full examples.
Microphone
import { microphone } from '@glyx-dev/react'Requires capability: "microphone" (and "audio").
One-shot WAV recording via the OS audio input.
| Method | Returns | Description |
|---|---|---|
microphone.listDevices() | Promise<{ name: string }[]> | Connected input devices |
microphone.record(durationMs?, deviceName?) | Promise<string> | Record for durationMs (default 3000) ms; resolves with the absolute path to a .wav file |
AI
import { ai } from '@glyx-dev/react'Requires capability: "ai"
| Method | Returns | Description |
|---|---|---|
ai.embed(text) | Promise<number[]> | 384-dim embedding vector (all-MiniLM-L6-v2) |
ai.generate(prompt, opts?) | Promise<string> | Text generation (Phi-2) |
ai.transcribe(audioPath, opts?) | Promise<string> | Speech-to-text (Whisper tiny) |
ai.unload.embed() | void | Drop the embed model from RAM immediately |
ai.unload.generate() | void | Drop the generate model (~1.7 GB) from RAM |
ai.unload.transcribe() | void | Drop the Whisper model from RAM |
System
import { system, battery, power, storage } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
system.getInfo() | Promise<SystemInfo> | OS name, version, arch, hostname, uptime |
system.getDarkMode() | Promise<boolean> | Whether the OS is in dark mode |
battery.getStatus() | Promise<BatteryStatus> | Charging state, level (0–1) |
power.preventSleep() | void | Keep the system awake |
power.allowSleep() | void | Release sleep prevention |
storage.listDrives() | Promise<Drive[]> | Available drives with free/total space |
Credentials (keychain)
import { credentials } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
credentials.set(key, value) | Promise<void> | Store in OS keychain |
credentials.get(key) | Promise<string|null> | Retrieve from OS keychain |
credentials.delete(key) | Promise<void> | Remove from OS keychain |
Backed by Windows Credential Manager, macOS Keychain, or Linux Secret Service.
IPC (inter-window)
import { ipc } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
ipc.send(windowId, message) | void | Send a string message to another window |
ipc.on('message', callback) | () => void | Listen for messages; returns unsubscribe |
Deep links
import { deeplink } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
deeplink.onOpen(callback) | void | Called when app is opened via a custom URL scheme |
Register your URL scheme in glyx.config.json under "deeplink": { "scheme": "myapp" }.
Crash reporting
import { crash } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
crash.getReports() | Promise<CrashReport[]> | List captured crash reports |
crash.clearReports() | Promise<void> | Delete all saved reports |
CrashReport: { id, timestamp, message, stackTrace }. Reports are captured automatically and persisted across restarts.
Auto-updater
import { updater } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
updater.check() | Promise<UpdateInfo|null> | Check GitHub Releases for a newer version |
updater.download(info) | Promise<string> | Download the update, returns local path |
updater.install(path) | Promise<void> | Apply update and schedule restart |
Performance
import { perf } from '@glyx-dev/react'| Method | Returns | Description |
|---|---|---|
perf.getMetrics() | Metrics | Current fps, frameTime, jsTime, layoutTime, gpuTime, memoryJS, nodeCount |
perf.onFrame(callback) | () => void | Called each frame with live metrics; returns unsubscribe |
perf.mark(name) | void | Insert a named timing mark |
Backend (custom commands)
import { backend } from '@glyx-dev/react'// Call a custom backend command
const result = await backend.myCommand({ arg1: 'value' })backend is a Proxy — any property access becomes a command call. Arguments are serialized to JSON and the return value is deserialized. Use it for both namespaced JS Plugins and custom Rust commands from Native Extensions.
Input
import { input } from '@glyx-dev/react'input.shortcut — focused shortcuts
Fires when the app window is focused. No OS registration.
| Method | Returns | Description |
|---|---|---|
input.shortcut.register(accelerator, cb) | number | Register a shortcut; returns an ID |
input.shortcut.unregister(id) | void | Remove a registered shortcut |
input.globalShortcut — system-wide shortcuts
Fires even when the app is backgrounded. Registered with the OS.
| Method | Returns | Description |
|---|---|---|
input.globalShortcut.register(accelerator, cb) | string | null | Register system shortcut; returns ID or null if denied |
input.globalShortcut.unregister(id) | void | Release the OS registration |
Accelerator format: modifiers joined with +, key last — "ctrl+s", "ctrl+shift+z", "meta+k", "f11", "escape".
Modifiers: ctrl / control, shift, alt, meta / cmd / win.
input.gamepads — gamepad input
| Method | Returns | Description |
|---|---|---|
input.gamepads.onInput(cb) | () => void | Fires each frame for every gamepad event; returns unsubscribe |
See the Window & Shortcuts page for full examples.
All Promise-returning APIs run on the Rust side — they never block the JS thread. Capabilities must be declared in glyx.config.json or the binding will throw at runtime.