Gets the application version for the Electron main process. Uses dynamic import to safely access the Electron app module only in main process context. Fallback: renderer version or npm package version if main process unavailable.

export const getAppVersionElectron = async (): Promise<string> => {
try {
// Only import app in Electron main process
if (globalThis.window === undefined) {
const electron = await import("electron");
return electron.app.getVersion();
}
// Fallback for renderer process
return getAppVersion();
} catch {
return (
process.env.VITE_APP_VERSION ?? process.env.npm_package_version ?? "1.0.0"
);
}
};
  • Returns Promise<string>

    A promise resolving to the current application version as a string.