Web
Explicit Google buttons, optional One Tap, Safari ITP, and browser compatibility.
Use an explicit Google button for browser login
Starting in 1.1.0, import browser APIs and adapters from
@pricava/react-native-google-credential/web. This entry point does not import
React Native or React Native Firebase at runtime and can be used with React,
Next.js, and Expo web. It renders Google's official button directly in the page.
There is no fallback dialog and no automatic switch from One Tap.
signInWithGoogleCredential() and existing zero-argument adapter calls retain
their One Tap behavior on web. Upgrading alone does not migrate a custom button:
replace the browser button with the component below. Keep native Android/iOS
screens on the existing root and adapter entry points, using platform-specific
files when sharing an Expo project.
React and Supabase
'use client';
import { useMemo } from 'react';
import {
GoogleSignInButton,
createSupabaseGoogleAuth,
} from '@pricava/react-native-google-credential/web';
export function GoogleLogin({ supabase, webClientId }) {
const authenticate = useMemo(
() => createSupabaseGoogleAuth({ supabase, webClientId }),
[supabase, webClientId],
);
return (
<GoogleSignInButton
authenticate={authenticate}
button={{ theme: 'outline', size: 'large', text: 'signin_with' }}
onSuccess={({ data, error }) => {
if (error) { /* Show your provider's error state. */ return; }
// Continue with data.session using your normal application navigation.
}}
onError={(error) => { /* Handle acquisition or thrown provider errors. */ }}
/>
);
}Memoize the adapter factory to avoid restarting a pending request on ordinary
renders. The component preserves the adapter's result contract: Supabase may
resolve with an { error } result, so inspect it before navigating. It exposes
loading/connecting status and a keyboard-accessible retry control. Pass
loadingLabel, connectingLabel, errorLabel, and retryLabel for your
application's language; Google's button itself uses the browser/account language
or button.locale. Style the outer container with className or style;
do not overlay, restyle, hide, or programmatically click Google's button.
The button is rendered before the user clicks. Google opens its sign-in UI from that genuine click, allowing an account to be added when no Google session exists. The adapter generates the OIDC nonce before rendering, then exchanges the credential with the matching original nonce. A new mount/retry creates a new nonce. Waiting for the user to click has no sign-in timeout; after a click, credential acquisition times out after two minutes. GIS does not expose reliable popup-close notifications; closing the popup may therefore result in that timeout.
Clerk
Use createClerkGoogleAuth or createClerkGoogleAuthAdapter from the same
/web entry point as the component's authenticate prop. The existing
authenticateWithGoogleOneTap token exchange and callback options are preserved;
the Clerk method name does not require the Google UI to be One Tap.
Firebase JavaScript SDK
The native Firebase entry point uses React Native Firebase. Browser applications
use the generic factory from /web with Firebase's JavaScript SDK:
import { GoogleAuthProvider, signInWithCredential } from 'firebase/auth';
import { createFirebaseGoogleAuthAdapter } from '@pricava/react-native-google-credential/web';
const authenticate = createFirebaseGoogleAuthAdapter({
credentialOptions: { webClientId },
createGoogleCredential: (idToken) => GoogleAuthProvider.credential(idToken),
signInWithCredential: (credential) => signInWithCredential(auth, credential),
});Custom backends and non-React applications
renderGoogleSignInButton(container, options) renders into an empty, connected
DOM element and returns a handle with destroy(). Destroy it on unmount and
handle onError. Use requestGoogleCredentialFromButton(options, container, buttonOptions, abortSignal) as an adapter's optional per-call
requestCredential strategy. Always abort a pending request when removing its
container. For a custom provider, signInWithGoogleAuthProvider from /web
retains the shared nonce generation and exchange behavior.
The optional request strategy is also accepted by the native adapters. Omit it to preserve their existing platform credential acquisition.
Safari and iOS browsers
One Tap passes itp_support: true by default. Set web.itpSupport: false to
opt out of Google's upgraded ITP experience. This does not guarantee a Google
session exists or override the user's privacy settings.
Google's compatibility documentation requires redirect mode on iOS browsers because of ITP. The low-level renderer supports it explicitly:
import { renderGoogleSignInButton } from '@pricava/react-native-google-credential/web';
const handle = await renderGoogleSignInButton(container, {
credentialOptions: { webClientId },
uxMode: 'redirect',
loginUri: 'https://example.com/auth/google',
});
// Call handle.destroy() when removing the button before navigation.Redirect mode submits the credential to a server endpoint; it does not resolve
an in-page adapter's promise. Register the exact HTTPS loginUri as an
Authorized redirect URI in Google Cloud. The server must validate Google's
g_csrf_token cookie/body pair, verify the ID token signature, issuer, audience,
expiry and any supplied nonce, then establish the provider/application session.
Keep secrets and nonce storage on the server. A static SPA must supply a server
endpoint or use its authentication provider's supported OAuth redirect flow.
The React component uses popup mode. Do not claim universal iOS compatibility for popup mode. Redirect integration depends on the application's backend.
Origins, headers, and browser settings
Register every deployed origin under the OAuth Web client's Authorized JavaScript origins. These origins are different:
http://localhost
http://localhost:8081
http://127.0.0.1:8081Allow https://accounts.google.com/gsi/client in your script policy and Google's
GIS endpoints in the appropriate frame/connect/style policies. For non-FedCM
popup communication, review Cross-Origin-Opener-Policy: same-origin-allow-popups.
Never disable browser privacy protections as an application requirement. Brave
Shields, content blockers, third-party sign-in settings, and missing Google
sessions can affect One Tap. The explicit button offers a separate user-initiated
flow, but cannot override a blocked script, denied browser permission, or a
provider configuration error.
GIS has a page-global client. The library permits one active credential request
or mounted button at a time and rejects concurrent requests with
request_in_progress rather than overwriting another request's client/nonce.
Do not initialize a second GIS client independently on the same page.