π gatsby-desktop-kit
A minimal, extensible starter kit for building cross-platform desktop apps using Gatsby + Electron + TypeScript.
β¨ Features
- β‘ Gatsby frontend + Electron backend
- π οΈ Minimal setup with maximum flexibility
- π₯οΈ Desktop-ready architecture
β οΈ Notice
- Currently tested only on Windows.
- macOS / Linux support is unverified β PRs welcome!
- If the app is still running, build commands may fail due to locked files. Kill Electron from your Task Manager if needed.
The /gatsby directory is essentially a slightly customized Gatsby frontend, which can be deployed to the web using services like Netlify.
By unifying data storage via localStorage, both the web and desktop (Electron) versions can share the same behavior from a single codebase.
π Usage
git clone https://github.com/tatsuoNakano/gatsby-desktop-kit-template
cd gatsby-desktop-kit-template
npm install
cd gatsby
npm install
cd ../
npm run dev:webπ Directory Structure
// This project is an Electron app powered by Gatsby for the frontend.
gatsby-desktop-kit-template/
βββ electron/ // Electron code
βββ gatsby/ // Gatsby frontend
β βββ .env.example // Gatsby-specific env template
βββ .env.example // Electron Root-level env template
βββ docs/ // Multilingual documentation (ja, zh, en)
βββ scripts/ // β οΈ Internal scripts β avoid editing unless necessary
π¦ Available npm Scripts
npm run devβ Runs Gatsby and Electron in parallel for development.
Internally runsdev:webanddev:appusingconcurrently.npm run dev:webβ Starts the Gatsby development server inside thegatsbyfolder.npm run dev:appβ Launches the Electron app usingts-nodewithelectron/main.jsas the entry point.
ποΈ Build Commands
npm run buildβ Full build: Generates static site with Gatsby, copies it to Electron, and builds the desktop app.npm run build:webβ Builds the static site usinggatsby buildwith path prefixing enabled.npm run build:appβ Useselectron-builderto package the Electron app for production.
π Asset Copying
npm run copyβ Copies Gatsbyβspublicoutput intoelectron/publicfor loading viafile://or local server.
π§Ή Clean Commands
npm run cleanβ Removes all build artifacts from both Gatsby and Electron.npm run clean:webβ Cleans Gatsbyβs.cacheandpublicdirectories.npm run clean:appβ Deletes Electronβsdistandpublicfolders.
βοΈ .env
Create a .env file from .env.example to configure ports and metadata:
ELECTRON_PORT=9003
GATSBY_PORT=9000
GATSBY_SERVE_PORT=9001π§ Architecture Note
This project uses electron-serve to unify the behavior between the web version and the desktop app.
By serving the Gatsby static output consistently, both environments share the same UI, routing, and storage logic. This makes development and testing much simpler and more reliable.
π€ Contributing
PRs and issues are welcome β especially for macOS/Linux support and improvements.
MIT License β Β© 2025