Social Login

Published on 3/3/2026

Tech stack

  • Since the hosting is in Cloudflare Workers, Better-Auth lib was selected.
  • It required Cloudflare Worker Node.JS compatibility to work.
  • Only plan is to support social login alone, without any DB requirements.
  • But have to store user email whenever a user login, for customer identification.

Setting up local https

For testing Google social login using better-auth, https connection was required. The steps were:

  • Install mkcert & libnss3-tools
  • mkcert -install => installs the local CA for firefox, chrome etc.
  • mkcert localhost 127.0.0.1 ::1 => generates certificates
  • configure vite to use https with the above certificates

Front end

The client side requires React based screens for login, logout etc. The Better-Auth-UI library is not compatible with React Router v7.

This is a valuable idea for an opensource contribution.

Notes

  • The redirect URL should be exact as in Better Auth docs. Not even trailing slash differences.
  • If frontend and backend are at different domains, environment variables, authClient config, Google console all should be correct.
  • CORS is also needed in such cases
  • Callback URL should be set in client side code when initiating sign in
  • The Hono server is the middle man who knows OAuth secrets. Sign in initiation & Redirection happens via Hono server
made with ♥️