🚧 Glyx is pre-release software. APIs may change before v1.0. Get started →
Documentation
API Reference

API Reference

Every export from glyx (@glyx-dev/react). React hooks and standard library — import those from 'react' directly.


Core components

ExportProps summary
Viewstyle, width, height, layout props, glyxDraggable, _glyxOnMount
Textstyle, numberOfLines, ellipsizeMode, selectable, onPress
PressableonPress, onPressIn, onPressOut, onLongPress, onHoverIn, onHoverOut, onRightPress, disabled, style (static or (state) => style)
TextInputvalue, onChangeText, placeholder, secureTextEntry, multiline, style, ref
ScrollViewstyle, onScroll, horizontal, bounces
Imagesrc, width, height, resizeMode ('cover'|'contain'|'stretch'|'center')
RepaintBoundarystyle, children — caches subtree as a GPU layer
VirtualizedListdata, renderItem, itemHeight, style
Canvasstyle, ref — 2D drawing surface
Canvas3Dstyle, ref — wgpu 3D surface
WindowControlsstyle — platform-native min/max/close buttons
Cameramirror, style, ref
Videosrc, style, ref, autoPlay, loop, muted

Form components

ExportKey props
Selectvalue, onValueChange, options: {label,value}[], placeholder, disabled
DatePickervalue: Date|string|null, onValueChange, disabled
TimePickervalue: 'HH:MM'|null, onValueChange, use24Hour, minuteStep
DateTimePickervalue: Date|string|null, onValueChange, use24Hour, minuteStep
Checkboxchecked, onChange, disabled, label
Switchvalue, onValueChange, disabled
RadioGroupvalue, onValueChange, children
Radiovalue, label, disabled — must be inside RadioGroup
Slidervalue, onValueChange, min, max, step, disabled
FileInputonFilesSelected, accept, multiple, label, disabled

Hooks

import { useWindowSize, useScreenSize, useMediaQuery, useDraggable } from '@glyx-dev/react'
HookReturnsDescription
useWindowSize(){ width, height }Current window size in logical pixels; updates on resize
useScreenSize(){ width, height }Primary monitor resolution
useMediaQuery(minWidth)booleantrue when window width ≥ minWidth
useDraggable(handlers)event handler propsAttach 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'
ExportSignatureDescription
openPopover(opts) → id: numberOpen a floating layer anchored to an element
closePopover(id: number) → voidClose a specific popover
PopoverHostcomponentAuto-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'
ExportSignatureDescription
render(element: ReactElement) → voidMount the root element. Call once at startup.
getEnv(name: string) → string | undefinedRead 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

MethodReturnsDescription
setFullscreen(bool)voidEnter / exit fullscreen
setMaximized(bool)voidMaximize / restore
setMinimized()voidMinimize to taskbar
isFullscreen()booleanCurrent fullscreen state
isMaximized()booleanCurrent maximized state
getWindowSize(){width, height}Window size in physical pixels
getScreenSize(){width, height}Primary monitor resolution

Window properties

MethodReturnsDescription
setTitle(title)voidChange the title bar text
setAlwaysOnTop(bool)voidPin window above others
platform()'windows'|'macos'|'linux'Host OS (cached)

Lifecycle

MethodReturnsDescription
close()voidClose this window
quit()voidExit the entire app
restart()voidQuit and re-launch
hideSplash()voidHide the splash screen

Utilities

MethodReturnsDescription
openExternal(url)voidOpen URL / mailto in system browser
collectMemory()voidTrigger 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 globals

Requires 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"

MethodReturnsDescription
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"

MethodReturnsDescription
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"

MethodReturnsDescription
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'
MethodReturnsDescription
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'
MethodReturnsDescription
clipboard.readText()Promise<string>Read text from clipboard
clipboard.writeText(text)Promise<void>Write text to clipboard

Notifications

import { notification } from '@glyx-dev/react'
MethodReturnsDescription
notification.send(opts)Promise<void>Show a desktop notification

opts: { title: string, body?: string, icon?: string }


System Tray

import { tray } from '@glyx-dev/react'
MethodReturnsDescription
tray.create(rgba, w, h, tooltip, menu?)numberCreate a tray icon. Returns handle ID (0 on failure).
tray.destroy(id)booleanRemove a tray icon.
tray.updateMenu(id, menu)booleanReplace the tray context menu.
tray.setTooltip(id, tooltip)voidUpdate the tooltip text.
tray.pollEvents()stringPoll 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.

MethodReturnsDescription
audio.play(src, opts?)Promise<PlayerHandle>Start playback of a file (MP3/FLAC/OGG/WAV); returns a handle
handle.pause() / handle.resume() / handle.play()voidControl playback
handle.stop()voidStop and release the sink
handle.seek(secs)Promise<void>Seek to position in seconds
handle.setVolume(0–1) / handle.getVolume()void / numberVolume control
handle.getTime()numberCurrent position in seconds
handle.getDuration()Promise<number>Total duration (-1 if unknown)
handle.onEnded(cb)voidFires 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.

MethodReturnsDescription
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"

MethodReturnsDescription
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()voidDrop the embed model from RAM immediately
ai.unload.generate()voidDrop the generate model (~1.7 GB) from RAM
ai.unload.transcribe()voidDrop the Whisper model from RAM

System

import { system, battery, power, storage } from '@glyx-dev/react'
MethodReturnsDescription
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()voidKeep the system awake
power.allowSleep()voidRelease sleep prevention
storage.listDrives()Promise<Drive[]>Available drives with free/total space

Credentials (keychain)

import { credentials } from '@glyx-dev/react'
MethodReturnsDescription
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'
MethodReturnsDescription
ipc.send(windowId, message)voidSend a string message to another window
ipc.on('message', callback)() => voidListen for messages; returns unsubscribe

Deep links

import { deeplink } from '@glyx-dev/react'
MethodReturnsDescription
deeplink.onOpen(callback)voidCalled 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'
MethodReturnsDescription
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'
MethodReturnsDescription
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'
MethodReturnsDescription
perf.getMetrics()MetricsCurrent fps, frameTime, jsTime, layoutTime, gpuTime, memoryJS, nodeCount
perf.onFrame(callback)() => voidCalled each frame with live metrics; returns unsubscribe
perf.mark(name)voidInsert 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.

MethodReturnsDescription
input.shortcut.register(accelerator, cb)numberRegister a shortcut; returns an ID
input.shortcut.unregister(id)voidRemove a registered shortcut

input.globalShortcut — system-wide shortcuts

Fires even when the app is backgrounded. Registered with the OS.

MethodReturnsDescription
input.globalShortcut.register(accelerator, cb)string | nullRegister system shortcut; returns ID or null if denied
input.globalShortcut.unregister(id)voidRelease 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

MethodReturnsDescription
input.gamepads.onInput(cb)() => voidFires 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.