Skip to content

API Overview

Overview of all LightShell JavaScript APIs.

LightShell exposes a complete set of native APIs through the window.lightshell object. All API methods are async and return Promises. No imports, no build tools, no node_modules — just call lightshell.* from any JavaScript in your app.

#NamespaceMethodsPriorityDescription
1windowsetTitle, setSize, getSize, setPosition, getPosition, minimize, maximize, fullscreen, restore, closeP0Window management and state
2fsreadFile, writeFile, readDir, exists, stat, mkdir, remove, watchP0File system access
3dialogopen, save, message, confirm, promptP0Native file pickers and message dialogs
4clipboardread, writeP0System clipboard text access
5systemplatform, arch, homeDir, tempDir, hostnameP0OS information and system paths
6appquit, version, dataDirP0Application lifecycle and metadata
7shellopenP0Open URLs and files with system defaults
8notifysendP1System notifications
9trayset, remove, onClickP1System tray icon and menu
10menusetP1Application menu bar
11storeget, set, delete, has, keys, clearP0Persistent key-value storage
12httpfetch, downloadP0CORS-free HTTP requests
13processexecP1Scoped system command execution
14shortcutsregister, unregister, unregisterAll, isRegisteredP1Global keyboard shortcuts
15updatercheck, install, checkAndInstall, onProgressP1Auto-update mechanism

P0 = core APIs available from day one. P1 = important APIs that ship in v1 but are secondary to core functionality.

A small example using multiple APIs together — a note-taking app that saves notes to the store, uses keyboard shortcuts, and sends a notification when done.

// Initialize the app
const settings = await lightshell.store.get('settings') || { theme: 'light' }
const version = await lightshell.app.version()
await lightshell.window.setTitle(`Notes — v${version}`)
// Load saved notes
const notes = await lightshell.store.get('notes') || []
renderNotes(notes)
// Save a new note
async function saveNote(text) {
notes.push({ id: Date.now(), text, created: new Date().toISOString() })
await lightshell.store.set('notes', notes)
renderNotes(notes)
}
// Export notes to a file
async function exportNotes() {
const path = await lightshell.dialog.save({
title: 'Export Notes',
defaultPath: 'notes.json',
filters: [{ name: 'JSON', extensions: ['json'] }]
})
if (path) {
await lightshell.fs.writeFile(path, JSON.stringify(notes, null, 2))
await lightshell.notify.send('Export Complete', `Saved ${notes.length} notes to ${path}`)
}
}
// Register a global shortcut for quick note capture
await lightshell.shortcuts.register('CommandOrControl+Shift+N', () => {
lightshell.window.restore()
document.getElementById('note-input').focus()
})
// Open external links in the system browser
document.addEventListener('click', (e) => {
const link = e.target.closest('a[href^="http"]')
if (link) {
e.preventDefault()
lightshell.shell.open(link.href)
}
})

LightShell also provides an event system for reacting to asynchronous changes. See the Events reference for the full list.

const unsubscribe = lightshell.on('window.resize', (data) => {
console.log(`Window resized to ${data.width}x${data.height}`)
})

All app settings, permissions, and build options are defined in lightshell.json. See the Configuration reference.

  • All APIs are async. Every method returns a Promise. Use await or .then().
  • No imports needed. The lightshell object is globally available on window — no import statements, no bundlers.
  • Permissive by default. Without a permissions key in lightshell.json, all operations are allowed. Add permissions only when you want to restrict access for security.
  • AI-friendly errors. Error messages include what was attempted, what went wrong, and how to fix it. They are designed to be useful to both humans and AI coding assistants.
  • Cross-platform. All APIs work identically on macOS and Linux. Platform differences are handled internally.