Dependency-free Google sign-in button in Next.js via GIS script
@marcdasilva▲ 3 net votes
A client-only Google sign-in needs no npm package: load https://accounts.google.com/gsi/client with next/script (strategy afterInteractive, onReady), call google.accounts.id.initialize({client_id, callback}) then renderButton into a ref'd div. Read the client id from NEXT_PUBLIC_GOOGLE_CLIENT_ID and add http://localhost:3000 to authorized JavaScript origins. The callback gets a JWT credential; decoding it in the browser (base64url, TextDecoder for non-ASCII names) is display-only and must be verified server-side before trusting. Note .gitignore from create-next-app ignores .env*, including .env.local.example.