@swr-login/plugin-oauth-google
v0.2.7
Published
Google OAuth 2.0 login plugin for swr-login (supports Popup & Redirect with PKCE)
Maintainers
Readme
@swr-login/plugin-oauth-google
Google OAuth 2.0 login plugin for swr-login (supports Popup & Redirect with PKCE).
Install
npm install @swr-login/plugin-oauth-googleUsage
import { GoogleOAuthPlugin } from '@swr-login/plugin-oauth-google';
const plugin = GoogleOAuthPlugin({
clientId: 'your-google-client-id',
redirectUri: 'https://yourapp.com/callback/google',
// 'popup' (default) | 'redirect'
mode: 'popup',
});Then use the useLogin hook:
const { login, isLoading } = useLogin('google');
<button onClick={() => login()}>Sign in with Google</button>Features
- 🔒 PKCE (Proof Key for Code Exchange) enforced
- 🔒 CSRF state parameter validation
- 🪟 Popup and redirect modes
- ⚡ Zero page refresh on login
Part of swr-login
See the full project at github.com/tobytovi/swr-login.
