This example demonstrates how to integrate the SpeedOf.Me speed test API into an Electron desktop application.
Electron is unique because it runs a full Chromium browser. The SpeedOf.Me API works directly in the renderer process - no WebView wrapper or JavaScript bridge needed!
npm install
SomApi.account = "YOUR_API_KEY";
SomApi.domainName = "your-domain.com";
npm start
npm run build
Electron App
├── Main Process (main.js)
│ └── BrowserWindow
│ └── preload.js (context bridge)
│
└── Renderer Process (index.html)
└── SpeedOf.Me API (direct)
▼
Results displayed directly in DOM
+ Optional IPC to main process
Unlike other desktop examples, Electron doesn't need a WebView wrapper because the renderer process IS a browser.
<meta http-equiv="Content-Security-Policy" content="
default-src 'self';
script-src 'self' 'unsafe-inline' https://speedof.me https://*.speedof.me;
connect-src https://*.speedof.me https://*.fastly.net wss://*.speedof.me;
style-src 'self' 'unsafe-inline';
">
Preload:
contextBridge.exposeInMainWorld('electronAPI', {
onTestCompleted: (result) => {
ipcRenderer.send('speed-test-completed', result);
}
});
Main:
ipcMain.on('speed-test-completed', (event, result) => {
console.log('Speed test completed:', result);
});
# macOS
npm run build -- --mac
# Windows
npm run build -- --win
# Linux
npm run build -- --linux
System Tray:
const { Tray } = require('electron');
const tray = new Tray('/path/to/icon.png');
Notifications:
new Notification({
title: 'Speed Test Complete',
body: `Download: ${result.download} Mbps`
}).show();
contextIsolation: true