npm create astro@latest -- --template basics
🧑🚀 Seasoned astronaut? Delete this file. Have fun!
Inside of your Astro + Electron project, you'll see the following folders and files:
/
├── public/
│ └── favicon.svg
├── electron/
│ ├── main.(js|ts) # Electron main process
│ └── preload.(js|ts) # Preload script for IPC
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ └── pages/
│ └── index.astro
└── package.json
Astro looks for .astro
or .md
files in the src/pages/
directory. Each page is exposed as a route based on its file name.
There's nothing special about src/components/
, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
The electron/
directory contains all Electron-specific code:
main.(js|ts)
handles the main process, window creation, and app lifecyclepreload.(js|ts)
provides secure IPC communication between main and renderer processes
Any static assets, like images, can be placed in the public/
directory.
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev |
Starts local dev server and electron app |
npm run build |
Build your production site and electron app |
npm run preview |
Preview your build locally, before deploying |
npm run electron:dev |
Run electron in development mode |
npm run electron:build |
Build electron app for production |
npm run astro ... |
Run CLI commands like astro add , astro check |
npm run astro -- --help |
Get help using the Astro CLI |
This template comes with:
- Secure IPC communication setup
- Hot-reload support in development
- Production build configuration
- Basic window management
- Cross-platform support
Feel free to check Astro documentation or Electron documentation, or jump into our Discord server.