Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Desktop App with Electron

Desktop App with Electron

Build cross-platform desktop applications with Electron and Google Antigravity

electrondesktopcross-platformnodejs
by antigravity-team
⭐0Stars
.antigravity
# Desktop App Development with Electron for Google Antigravity

Create professional cross-platform desktop applications using Electron with Google Antigravity IDE.

## Electron Main Process

```typescript
// electron/main.ts
import { app, BrowserWindow, ipcMain, Menu, Tray, nativeImage } from "electron";
import { join } from "path";
import { autoUpdater } from "electron-updater";
import Store from "electron-store";

const store = new Store();
let mainWindow: BrowserWindow | null = null;
let tray: Tray | null = null;

const isDev = process.env.NODE_ENV === "development";

async function createWindow() {
  const { width, height, x, y } = store.get("windowBounds", { width: 1200, height: 800 }) as {
    width: number; height: number; x?: number; y?: number;
  };

  mainWindow = new BrowserWindow({
    width, height, x, y,
    minWidth: 800,
    minHeight: 600,
    frame: false,
    titleBarStyle: "hiddenInset",
    webPreferences: {
      nodeIntegration: false,
      contextIsolation: true,
      sandbox: true,
      preload: join(__dirname, "preload.js")
    }
  });

  mainWindow.on("close", () => {
    if (mainWindow) {
      store.set("windowBounds", mainWindow.getBounds());
    }
  });

  if (isDev) {
    mainWindow.loadURL("http://localhost:5173");
    mainWindow.webContents.openDevTools();
  } else {
    mainWindow.loadFile(join(__dirname, "../renderer/index.html"));
  }

  setupAutoUpdater();
}

function createTray() {
  const icon = nativeImage.createFromPath(join(__dirname, "../assets/tray-icon.png"));
  tray = new Tray(icon.resize({ width: 16, height: 16 }));
  
  const contextMenu = Menu.buildFromTemplate([
    { label: "Show App", click: () => mainWindow?.show() },
    { type: "separator" },
    { label: "Quit", click: () => app.quit() }
  ]);
  
  tray.setContextMenu(contextMenu);
  tray.on("click", () => mainWindow?.show());
}

function setupAutoUpdater() {
  autoUpdater.checkForUpdatesAndNotify();
  
  autoUpdater.on("update-available", () => {
    mainWindow?.webContents.send("update-available");
  });
  
  autoUpdater.on("update-downloaded", () => {
    mainWindow?.webContents.send("update-downloaded");
  });
}

// IPC Handlers
ipcMain.handle("get-app-path", () => app.getPath("userData"));

ipcMain.handle("read-file", async (_, filePath: string) => {
  const fs = await import("fs/promises");
  return fs.readFile(filePath, "utf-8");
});

ipcMain.handle("write-file", async (_, filePath: string, content: string) => {
  const fs = await import("fs/promises");
  await fs.writeFile(filePath, content, "utf-8");
});

ipcMain.handle("show-dialog", async (_, options) => {
  const { dialog } = await import("electron");
  return dialog.showOpenDialog(mainWindow!, options);
});

ipcMain.on("install-update", () => {
  autoUpdater.quitAndInstall();
});

app.whenReady().then(() => {
  createWindow();
  createTray();
});

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") app.quit();
});

app.on("activate", () => {
  if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
```

## Preload Script

```typescript
// electron/preload.ts
import { contextBridge, ipcRenderer, IpcRendererEvent } from "electron";

type Listener = (...args: unknown[]) => void;

const electronAPI = {
  // File operations
  readFile: (path: string) => ipcRenderer.invoke("read-file", path),
  writeFile: (path: string, content: string) => ipcRenderer.invoke("write-file", path, content),
  showOpenDialog: (options: Electron.OpenDialogOptions) => ipcRenderer.invoke("show-dialog", options),
  
  // App info
  getAppPath: () => ipcRenderer.invoke("get-app-path"),
  
  // Window controls
  minimize: () => ipcRenderer.send("window-minimize"),
  maximize: () => ipcRenderer.send("window-maximize"),
  close: () => ipcRenderer.send("window-close"),
  
  // Updates
  onUpdateAvailable: (callback: Listener) => {
    const handler = (_: IpcRendererEvent, ...args: unknown[]) => callback(...args);
    ipcRenderer.on("update-available", handler);
    return () => ipcRenderer.removeListener("update-available", handler);
  },
  onUpdateDownloaded: (callback: Listener) => {
    const handler = (_: IpcRendererEvent, ...args: unknown[]) => callback(...args);
    ipcRenderer.on("update-downloaded", handler);
    return () => ipcRenderer.removeListener("update-downloaded", handler);
  },
  installUpdate: () => ipcRenderer.send("install-update")
};

contextBridge.exposeInMainWorld("electron", electronAPI);

export type ElectronAPI = typeof electronAPI;
```

## Renderer Types and Hook

```typescript
// src/types/electron.d.ts
import type { ElectronAPI } from "../../electron/preload";

declare global {
  interface Window {
    electron: ElectronAPI;
  }
}

// src/hooks/useElectron.ts
import { useEffect, useState, useCallback } from "react";

export function useElectron() {
  const [updateAvailable, setUpdateAvailable] = useState(false);
  const [updateDownloaded, setUpdateDownloaded] = useState(false);

  useEffect(() => {
    const unsubAvailable = window.electron.onUpdateAvailable(() => {
      setUpdateAvailable(true);
    });
    
    const unsubDownloaded = window.electron.onUpdateDownloaded(() => {
      setUpdateDownloaded(true);
    });

    return () => {
      unsubAvailable();
      unsubDownloaded();
    };
  }, []);

  const openFile = useCallback(async () => {
    const result = await window.electron.showOpenDialog({
      properties: ["openFile"],
      filters: [{ name: "All Files", extensions: ["*"] }]
    });
    
    if (!result.canceled && result.filePaths[0]) {
      return window.electron.readFile(result.filePaths[0]);
    }
    return null;
  }, []);

  const saveFile = useCallback(async (path: string, content: string) => {
    await window.electron.writeFile(path, content);
  }, []);

  return {
    openFile,
    saveFile,
    updateAvailable,
    updateDownloaded,
    installUpdate: window.electron.installUpdate
  };
}
```

## Best Practices

1. **Enable context isolation** and disable node integration
2. **Use preload scripts** for secure IPC
3. **Implement auto-updates** for seamless upgrades
4. **Store user preferences** with electron-store
5. **Handle platform differences** gracefully
6. **Minimize main process blocking** operations
7. **Sign and notarize** for distribution

Google Antigravity accelerates Electron development with secure IPC patterns and cross-platform best practices.

When to Use This Prompt

This electron prompt is ideal for developers working on:

  • electron applications requiring modern best practices and optimal performance
  • Projects that need production-ready electron code with proper error handling
  • Teams looking to standardize their electron development workflow
  • Developers wanting to learn industry-standard electron patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their electron implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the electron code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this electron prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For electron projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...