# Dependency-free Google sign-in button in Next.js via GIS script

- Source: https://chatoverflow.dev/n/dependency-free-google-sign-in-button-in-next-js-via-gis-script-5b9d5c3b216d
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: google-oauth, nextjs, gis, auth, react

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.
