DEV Community

Alex Spinov
Alex Spinov

Posted on

Neutralinojs Has a Free API — Here's How to Build Lightweight Desktop Apps

Neutralinojs is a lightweight framework for building cross-platform desktop apps using JavaScript, HTML, and CSS. Unlike Electron, it uses the OS native webview — resulting in apps under 5MB.

Getting Started

npm install -g @neutralinojs/neu
neu create my-app
cd my-app
neu run
Enter fullscreen mode Exit fullscreen mode

neutralino.config.json

{
  "applicationId": "com.example.myapp",
  "defaultMode": "window",
  "port": 0,
  "url": "/",
  "modes": {
    "window": {
      "title": "My App",
      "width": 800,
      "height": 600,
      "minWidth": 400,
      "minHeight": 300
    }
  },
  "cli": {
    "binaryName": "myapp",
    "resourcesPath": "/resources/",
    "clientLibrary": "/resources/js/neutralino.js"
  }
}
Enter fullscreen mode Exit fullscreen mode

File System Operations

// Read a file
const content = await Neutralino.filesystem.readFile("./data/config.json");
console.log(JSON.parse(content));

// Write a file
await Neutralino.filesystem.writeFile("./output.txt", "Hello from Neutralino!");

// List directory
const entries = await Neutralino.filesystem.readDirectory("./data");
entries.forEach(e => console.log(`${e.type}: ${e.entry}`));
Enter fullscreen mode Exit fullscreen mode

System Commands

// Execute a command
const result = await Neutralino.os.execCommand("ls -la");
console.log(result.stdOut);

// Open URL in browser
await Neutralino.os.open("https://neutralino.js.org");

// Show notification
await Neutralino.os.showNotification("My App", "Task completed!");
Enter fullscreen mode Exit fullscreen mode

Dialogs

// Open file dialog
const entries = await Neutralino.os.showOpenDialog("Select files", {
  filters: [
    { name: "Images", extensions: ["jpg", "png", "gif"] },
    { name: "All files", extensions: ["*"] }
  ]
});

// Save dialog
const savePath = await Neutralino.os.showSaveDialog("Save file");

// Message box
await Neutralino.os.showMessageBox("Info", "Operation completed!");
Enter fullscreen mode Exit fullscreen mode

Window Management

await Neutralino.window.setTitle("Updated Title");
await Neutralino.window.setSize({ width: 1024, height: 768 });
await Neutralino.window.center();
await Neutralino.window.setFullScreen();
Enter fullscreen mode Exit fullscreen mode

Build for Distribution

neu build --release
# Outputs: dist/myapp-linux_x64, dist/myapp-mac_x64, dist/myapp-win_x64.exe
Enter fullscreen mode Exit fullscreen mode

Need to extract or automate web content at scale? Check out my web scraping tools on Apify — no coding required. Or email me at spinov001@gmail.com for custom solutions.

Top comments (0)