🚧 VeloxKit is pre-release software. APIs may change before v1.0. Get started →
Documentation
APIs & Bindings
window

window Stable WINMACLNX

Control the app window, open secondary windows, communicate between them, and manage the application lifecycle.

Import

import { veloxWindow, ipc } from 'veloxkit'

veloxWindow

Window state

MethodReturnsDescription
veloxWindow.setFullscreen(bool)voidEnter / exit fullscreen (covers taskbar)
veloxWindow.setMaximized(bool)voidMaximize / restore
veloxWindow.setMinimized()voidMinimize to taskbar
veloxWindow.isFullscreen()booleanCurrent fullscreen state
veloxWindow.isMaximized()booleanCurrent maximized state

Size and position

MethodReturnsDescription
veloxWindow.getWindowSize(){width, height}Current window size in physical pixels
veloxWindow.getScreenSize(){width, height}Primary monitor resolution

Window properties

MethodReturnsDescription
veloxWindow.setTitle(title)voidChange the window title bar text
veloxWindow.setAlwaysOnTop(bool)voidPin window above others
veloxWindow.platform()'windows' | 'macos' | 'linux'Host OS (cached, never re-queried)

Lifecycle

MethodReturnsDescription
veloxWindow.close()voidClose this window (main window also exits the app)
veloxWindow.quit()voidExit the entire application
veloxWindow.restart()voidQuit and re-launch the same executable
veloxWindow.hideSplash()voidHide the splash screen overlay

Multi-window

veloxWindow.create(opts?) → Promise<{ id: number, send(msg: string): void }>

Opens a secondary window running the same app bundle. Returns a handle for IPC messaging.

const win = await veloxWindow.create({
  title:  'Inspector',
  width:  400,
  height: 600,
})
 
// Send a message to that window
win.send(JSON.stringify({ type: 'init', payload: 42 }))

Options

OptionTypeDescription
titlestringWindow title
widthnumberInitial width in physical pixels
heightnumberInitial height in physical pixels

ipc — inter-window messaging

Send strings between windows. Both sender and receiver must import ipc.

import { ipc } from 'veloxkit'

ipc.send(targetHandle, message)

Send a message to another window. Use the id from veloxWindow.create().

ipc.send(win.id, JSON.stringify({ type: 'update', data: newValue }))

ipc.on('message', callback)

Listen for messages in the receiving window. Returns an unsubscribe function.

const unsub = ipc.on('message', (raw) => {
  const msg = JSON.parse(raw)
  if (msg.type === 'update') {
    setData(msg.data)
  }
})
 
// Cleanup:
useEffect(() => unsub, [])

Splash screen

Configure in veloxkit.config.json:

veloxkit.config.json
{
  "splash": {
    "image":      "assets/splash.png",
    "background": "#0D0D14",
    "minimumMs":  1200
  }
}

Hide programmatically once your app is ready:

// After loading initial data:
await db.open('app.db')
await runMigrations()
veloxWindow.hideSplash()

minimumMs guarantees the splash stays visible for at least that long, even if hideSplash() is called immediately. The splash auto-hides after 30 seconds as a safety net.


Custom title bar

Remove the native title bar with decorations: false in config:

veloxkit.config.json
{
  "window": {
    "decorations": false
  }
}

Then build your own using the WindowControls component (built into VeloxKit):

import { WindowControls } from 'veloxkit'
 
function TitleBar() {
  return (
    <View
      veloxDraggable   // drag this region to move the window
      style={{
        height: 38,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
        paddingHorizontal: 12,
        backgroundColor: '#0D0D14',
      }}
    >
      <Text style={{ fontSize: 13, color: '#9999cc' }}>My App</Text>
      <WindowControls />
    </View>
  )
}

WindowControls automatically renders the correct buttons for each platform (traffic lights on macOS, minimize / maximize / close on Windows).

The veloxDraggable prop marks the view as a drag region. Buttons and inputs inside the region work normally — only bare View areas drag the window.

See the Custom Title Bar guide for a full walkthrough.


Examples

Toggle fullscreen on F11

import { veloxWindow } from 'veloxkit'
import { addKeyListener } from 'veloxkit'
import { useEffect } from 'react'
 
function App() {
  useEffect(() => {
    const unsub = addKeyListener(({ key, pressed }) => {
      if (pressed && key === 'F11') {
        veloxWindow.setFullscreen(!veloxWindow.isFullscreen())
      }
    })
    return unsub
  }, [])
 
  // ...
}

Restart after applying an update

// After writing a new binary to disk:
await applyUpdate(binaryBlob)
veloxWindow.restart()

Inspector window (dev tool pattern)

// Main window:
const inspectorWin = await veloxWindow.create({
  title: 'Dev Inspector',
  width: 500,
  height: 700,
})
 
// Push state changes to the inspector:
function onStateChange(state) {
  inspectorWin.send(JSON.stringify({ type: 'state', state }))
}
 
// Inspector window:
ipc.on('message', (raw) => {
  const { type, state } = JSON.parse(raw)
  if (type === 'state') setInspectedState(state)
})

veloxWindow.platform() is determined at compile time and cached after the first call — it never triggers a native round-trip on subsequent reads.