
Security News
AI Slop Is Polluting Bug Bounty Platforms with Fake Vulnerability Reports
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
astro-electron
Advanced tools
Astro-Electron is an integration designed to seamlessly incorporate Electron into Astro projects. It simplifies the process of setting up Electron, providing a streamlined development experience for building cross-platform desktop applications with Astro and Electron.
npm add astro-electron electron
Electron doesn't really work with anything other than npm or Yarn Classic, so if you're pnpm user, I feel you, but there is not much you can do about it, just say hi to your old friend npm, you are going to spend a lot of time together 😅
Your app won't run in Electron without some additional setup. Follow the steps below to get started.
Modify your astro.config.js
to include the astro-electron
integration:
import { defineConfig } from "astro/config";
import electron from "astro-electron";
export default defineConfig({
integrations: [electron()],
});
Modify your package.json
to include an entrypoint:
{
"main": "dist-electron/main.js"
}
.gitignore
Add the dist-electron
directory to your .gitignore
file:
# Electron
dist-electron/
Create the src/electron
directory and add the required main.ts
file and the optional preload.ts
file.
Please note this is just an minimal example, refer to Electron docs for more information.
// src/electron/main.ts
import * as url from "url";
import { app, BrowserWindow } from "electron";
app.whenReady().then(async () => {
const win = new BrowserWindow({
title: "Main window",
webPreferences: {
preload: url.fileURLToPath(new URL("preload.mjs", import.meta.url)),
},
});
// You can use `process.env.VITE_DEV_SERVER_URL` when the vite command is called `serve`
if (process.env.VITE_DEV_SERVER_URL) {
await win.loadURL(process.env.VITE_DEV_SERVER_URL);
win.webContents.openDevTools();
} else {
// Load your file
await win.loadFile("dist/index.html");
}
});
// src/electron/preload.ts
console.log("preload.ts");
astro-electron
allows for customization of the Electron setup. You can pass specific configuration options to tailor the integration to your project's needs:
export default defineConfig({
integrations: [
electron({
main: {
entry: "src/electron/main.ts", // Path to your Electron main file
vite: {}, // Vite-specific configurations (by default we use the same config as your Astro project)
},
preload: {
input: "src/electron/preload.ts", // Path to your Electron preload file
vite: {}, // Vite-specific configurations (by default we use the same config as your Astro project)
},
renderer: {
// Renderer-specific configurations (if needed)
},
}),
],
});
For more information on the available configuration options, refer to the vite-plugin-electron docs.
Your app will most likely need some static assets like fonts, videos etc. (for images you should use Image
from astro:assets
)
To make them available in Electron you need to explicitly use a /public
directory in your paths, unlike in a regular Astro project.
This integration does not include any building or publishing functionality, it's up to you to choose the best option for your project, but we recommend using Electron Forge.
astro-electron
is open-source software licensed under the MIT License.
FAQs
Build cross-platform desktop apps with Electron and Astro
The npm package astro-electron receives a total of 16 weekly downloads. As such, astro-electron popularity was classified as not popular.
We found that astro-electron demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
Research
Security News
The Socket Research team investigates a malicious Python package disguised as a Discord error logger that executes remote commands and exfiltrates data via a covert C2 channel.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.