This project implements GitHub OAuth authentication in Electron using Better Auth.
First, navigate to the hono directory, install dependencies, and configure environment variables:
cd hono
bun install
cp .env.example .envThen configure the environment variables in the .env file as needed (including GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET, etc.).
Run Prisma migrations to set up the database schema:
bunx prisma migrate devThis command will:
- Create the database if it doesn't exist
- Apply all pending migrations
- Generate the Prisma Client
Note: If you need to reset the database, you can use:
bunx prisma migrate resetRun in the hono directory:
bun run devThe backend service runs on http://localhost:3000 by default (modify according to your actual setup).
Run in the project root directory:
bun installbun run devbun run buildAfter the build completes, open the generated executable file.
Configure in your GitHub OAuth application settings:
- Homepage URL:
http://localhost:3000(modify according to your actual Hono service setup) - Authorization callback URL:
http://localhost:5173(modify according to your actual Electron dev server setup)
Configure in your GitHub OAuth application settings:
- Homepage URL: Your actual Hono backend service URL (e.g.,
https://your-api-domain.com) - Authorization callback URL:
{custom-protocol}://index.htmlor other format as needed- Example: If your custom protocol is
myapp, usemyapp://index.html
- Example: If your custom protocol is
The custom protocol must be consistent in the following two files:
src/constants/protocol.ts(Electron main app)hono/src/constants/protocol.ts(Hono backend service)
Modify the PROTOCOL constant value in both files, for example:
export const PROTOCOL = 'your-custom-protocol'Important Notes:
- The protocol values in both files must be consistent
- The protocol value should conform to URL scheme specifications (lowercase letters, numbers, hyphens)
- You need to rebuild the Electron app after making changes for them to take effect
For detailed configuration and usage instructions about the Hono backend, please refer to hono/README.md.