π 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:web
anddev:app
usingconcurrently
.npm run dev:web
β Starts the Gatsby development server inside thegatsby
folder.npm run dev:app
β Launches the Electron app usingts-node
withelectron/main.js
as 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 build
with path prefixing enabled.npm run build:app
β Useselectron-builder
to package the Electron app for production.
π Asset Copying
npm run copy
β Copies Gatsbyβspublic
output intoelectron/public
for 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.cache
andpublic
directories.npm run clean:app
β Deletes Electronβsdist
andpublic
folders.
βοΈ .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