Skip to main content

API reference

Complete TypeScript surface exported from react-native-nitro-google-signin. For flows and examples, see Usage and Quick start.

Package exports

ExportKindDescription
GoogleOneTapSignInobjectMain API (Universal / One Tap sign-in)
GoogleSignInButtoncomponentNative branded sign-in button (HybridView)
GoogleSignInButtonHostcomponentLow-level Nitro host (same tree as GoogleSignInButton)
useGoogleSignInFromButtonhookSign-in cascade for custom UI
GOOGLE_SIGN_IN_BUTTON_HEIGHTconst48 — recommended button height (pt/dp)
OneTapResponseTypesconstString literals for OneTapResponseType
statusCodesconstError code string constants
GoogleSignInErrorclassThrown native/JS errors with code
isSuccessResponsefunctionType guard
isNoSavedCredentialFoundResponsefunctionType guard
isCancelledResponsefunctionType guard
isErrorWithCodefunctionGoogleSignInError type guard
NitroGoogleSigninobjectDeprecated alias of GoogleOneTapSignIn
OneTapConfigureParamstypeconfigure() options
OneTapResponsetypeSign-in method return value
OneTapResponseTypetype'success' | 'noSavedCredentialFound' | 'cancelled'
OneTapSuccessDatatypeSuccess payload (user, idToken, serverAuthCode)
OneTapUsertypeProfile fields on success
OneTapAuthorizationResulttyperequestScopes() result
OneTapSignInParamstypePlaceholder (empty) for API parity
OneTapCreateAccountParamstypePlaceholder (empty) for API parity
OneTapExplicitSignInParamstypePlaceholder (empty) for API parity
StatusCodetypeUnion of statusCodes values
GoogleSignInButtonPropstypeButton component props
GoogleSignInButtonColorSchemetype'light' | 'dark'
GoogleSignInButtonNativeSizetype'standard' | 'wide' | 'icon'
GoogleSignInButtonContentAlignmenttype'center' | 'leading' | 'trailing'
GoogleSignInButtonSignInBehaviortype'credentialManager' | 'buttonFlow' | 'none'
GoogleSignInButtonViewPropstypeLow-level HybridView props
GoogleSignInButtonViewMethodstypeLow-level HybridView methods
GoogleSignInButtonReftypehybridRef callback type

UseGoogleSignInFromButtonOptions is used by useGoogleSignInFromButton but not re-exported from the package root — see useGoogleSignInFromButton.


GoogleOneTapSignIn

Singleton-style object backed by the Nitro hybrid NitroGoogleSignin. Call configure() once before any other method.

configure(params: OneTapConfigureParams): void

ParameterTypeRequiredDefaultDescription
webClientIdstringyesWeb OAuth 2.0 client ID (*.apps.googleusercontent.com), or 'autoDetect' to read from native config (Android default_web_client_id, iOS WEB_CLIENT_ID in plist).
iosClientIdstring | nullnoplist CLIENT_IDiOS OAuth client ID for GIDConfiguration.clientID. iOS: required via this field or GoogleService-Info.plist CLIENT_ID. Ignored on Android.
offlineAccessbooleannofalseWhen true, success responses may include serverAuthCode for your backend.
hostedDomainstring | nullnoRestrict sign-in to a Google Workspace domain (e.g. example.com).
noncestring | nullnoauto SHA-256 hexNonce embedded in the ID token. If omitted, native code generates a random SHA-256 hex nonce per request.
scopesstring[] | nullno[]OAuth scope URLs requested with sign-in / authorization (e.g. https://www.googleapis.com/auth/drive.file).
autoSelectOnSignInbooleannofalseAndroid: when true, signIn() may auto-select if exactly one authorized account exists. When false, shows account UI when possible.

Throws / errors

ConditionResult
webClientId: 'autoDetect' without generated Android resource or iOS WEB_CLIENT_IDError / not configured (add config files or pass explicit Web ID)
iOS missing iosClientId and no plist CLIENT_IDConfigure fails — add GoogleService-Info.plist or pass iosClientId
Any sign-in method before configure()GoogleSignInError / not configured

checkPlayServices(showErrorResolutionDialog?: boolean): Promise<void>

ParameterTypeDefaultDescription
showErrorResolutionDialogbooleantrueAndroid: if Play Services are missing/outdated and the error is user-resolvable, show Google’s resolution dialog.
PlatformBehavior
AndroidResolves if Play Services available; throws GoogleSignInError with PLAY_SERVICES_NOT_AVAILABLE otherwise.
iOSResolves immediately (no-op).

signIn(): Promise<OneTapResponse>

Attempts a low-friction sign-in without forcing the full account picker when possible.

PlatformNative behavior
AndroidCredential Manager with authorized accounts only (filterByAuthorizedAccounts: true). Respects autoSelectOnSignIn.
iOSIf GIDSignIn.sharedInstance.currentUser exists → success; else restorePreviousSignIn().

Returns OneTapResponse (never throws for user cancel — use type: 'cancelled').


createAccount(): Promise<OneTapResponse>

Interactive flow that can show all Google accounts on the device (including accounts not yet authorized for your app).

PlatformNative behavior
AndroidCredential Manager, filterByAuthorizedAccounts: false.
iOSInteractive signIn(withPresenting:).

presentExplicitSignIn(): Promise<OneTapResponse>

Explicit Sign in with Google UI.

PlatformNative behavior
AndroidGetSignInWithGoogleOption — account dialog (all accounts, add account).
iOSSame interactive sign-in as createAccount().

Use when you want the traditional button-style account chooser on Android instead of the Credential Manager bottom sheet.


requestScopes(scopes: string[]): Promise<OneTapAuthorizationResult>

Request additional OAuth scopes after the user is signed in. User may see a consent UI.

ParameterTypeDescription
scopesstring[]Full scope URLs to request (not short names).
Field (result)TypeDescription
serverAuthCodestring | nullAuthorization code for your backend, or null if unavailable.

Requires prior successful sign-in (configure() + active session).


signOut(): Promise<void>

Clears the Google Sign-In session in the native SDK.

PlatformNotes
iOSGIDSignIn.sharedInstance.signOut().
AndroidCredential Manager has no global sign-out; matches One Tap semantics — automatic sign-in is disabled until the next successful interactive sign-in. Clear your app session in JS.

revokeAccess(emailOrUniqueId: string): Promise<void>

ParameterTypeDescription
emailOrUniqueIdstringUser identifier (email or Google account id). Android: parameter is ignored; behaves like signOut(). iOS: GIDSignIn.sharedInstance.disconnect — revokes app access for the user.

Types

OneTapConfigureParams

interface OneTapConfigureParams {
webClientId: string
iosClientId?: string | null
offlineAccess?: boolean
hostedDomain?: string | null
nonce?: string | null
scopes?: string[] | null
autoSelectOnSignIn?: boolean
}

See configure() for field details.


OneTapResponseType

type OneTapResponseType =
| 'success'
| 'noSavedCredentialFound'
| 'cancelled'
ValueMeaning
'success'User signed in; data is OneTapSuccessData.
'noSavedCredentialFound'No saved credential / no previous sign-in to restore — run createAccount() or presentExplicitSignIn() next.
'cancelled'User dismissed UI (not an thrown error).

OneTapResponseTypes

Const object mirroring OneTapResponseType for comparisons without string literals:

const OneTapResponseTypes = {
success: 'success',
noSavedCredentialFound: 'noSavedCredentialFound',
cancelled: 'cancelled',
} as const

Example: response.type === OneTapResponseTypes.success


OneTapResponse

interface OneTapResponse {
type: OneTapResponseType
data: OneTapSuccessData | null
}
typedata
'success'Non-null OneTapSuccessData
'noSavedCredentialFound'null
'cancelled'null

OneTapSuccessData

interface OneTapSuccessData {
user: OneTapUser
idToken: string
serverAuthCode: string | null
}
FieldTypeDescription
userOneTapUserProfile fields from Google ID token / credential.
idTokenstringOpenID Connect ID token (JWT). Verify on your backend with Google’s keys.
serverAuthCodestring | nullOAuth 2.0 server auth code when offlineAccess: true and/or scopes were granted; otherwise often null until requestScopes / authorization helper runs.

OneTapUser

interface OneTapUser {
id: string
email: string | null
name: string | null
givenName: string | null
familyName: string | null
photo: string | null
}
FieldTypeDescription
idstringStable Google account id (JWT sub / uniqueId). Prefer over email for primary keys.
emailstring | nullEmail address when available.
namestring | nullFull display name.
givenNamestring | nullFirst name.
familyNamestring | nullLast name.
photostring | nullProfile picture URL.

OneTapAuthorizationResult

interface OneTapAuthorizationResult {
serverAuthCode: string | null
}

Returned only from requestScopes().


Placeholder param types

Reserved for API parity with the Universal One Tap surface (currently no fields):

type OneTapSignInParams = Record<string, never>
type OneTapCreateAccountParams = Record<string, never>
type OneTapExplicitSignInParams = Record<string, never>

Sign-in methods take no arguments: signIn(), createAccount(), presentExplicitSignIn().


Response helpers

FunctionSignatureNarrows to
isSuccessResponse(response: OneTapResponse) => booleantype === 'success' and data != null
isNoSavedCredentialFoundResponse(response: OneTapResponse) => booleantype === 'noSavedCredentialFound'
isCancelledResponse(response: OneTapResponse) => booleantype === 'cancelled'
const response = await GoogleOneTapSignIn.signIn()

if (isSuccessResponse(response)) {
const { user, idToken, serverAuthCode } = response.data
}

if (isNoSavedCredentialFoundResponse(response)) {
const next = await GoogleOneTapSignIn.createAccount()
}

if (isCancelledResponse(response)) {
// user dismissed UI
}

Responses vs throws: cancelled and noSavedCredentialFound are normal OneTapResponse values. GoogleSignInError is thrown for Play Services, misconfiguration, in-progress state, etc.


Errors

GoogleSignInError

class GoogleSignInError extends Error {
name: 'GoogleSignInError'
code: StatusCode
userInfo?: Record<string, string>
}
PropertyDescription
codeOne of StatusCode / statusCodes.
messageHuman-readable message from native layer.
userInfoOptional key–value metadata (e.g. Play Services status on Android).

statusCodes

const statusCodes = {
ONE_TAP_START_FAILED: 'ONE_TAP_START_FAILED',
PLAY_SERVICES_NOT_AVAILABLE: 'PLAY_SERVICES_NOT_AVAILABLE',
IN_PROGRESS: 'IN_PROGRESS',
SIGN_IN_REQUIRED: 'SIGN_IN_REQUIRED',
SIGN_IN_CANCELLED: 'SIGN_IN_CANCELLED',
} as const

type StatusCode = (typeof statusCodes)[keyof typeof statusCodes]
CodeWhen
ONE_TAP_START_FAILEDCredential Manager / Google Sign-In request failed (not user cancel).
PLAY_SERVICES_NOT_AVAILABLEAndroid — Play Services missing or outdated (checkPlayServices or sign-in).
IN_PROGRESSNo Activity / view controller, or sign-in called before configure().
SIGN_IN_REQUIREDReserved — user must sign in first.
SIGN_IN_CANCELLEDReserved / parity — prefer isCancelledResponse() on responses.

isErrorWithCode(error: unknown): error is GoogleSignInError

try {
await GoogleOneTapSignIn.checkPlayServices()
} catch (e) {
if (isErrorWithCode(e) && e.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
// ...
}
}

GoogleSignInButton

Native GIDSignInButton (iOS) / SignInButton (Android) as a Nitro HybridView. See Google Sign-In button.

GoogleSignInButtonProps

Combines native view props, React Native ViewProps subset, and sign-in callbacks.

Sign-in & callbacks

PropTypeDefaultDescription
signInBehaviorGoogleSignInButtonSignInBehavior'credentialManager'Built-in flow on press (see below).
onSignInSuccess(data: OneTapSuccessData) => voidCalled when built-in sign-in succeeds.
onSignInError(error: unknown) => voidCalled on thrown errors during built-in sign-in.
onPress() => void | Promise<void>Runs before native sign-in when built-in behavior is active; with signInBehavior="none", only this handler runs.
loadingbooleanhook loadingWhen true, disables the button (merged with internal loading state).
hybridRef(ref: GoogleSignInButtonRef) => voidNitro hybrid view ref callback.

Built-in sign-in is enabled when signInBehavior !== 'none' or onSignInSuccess / onSignInError is set.

Native appearance (GoogleSignInButtonViewProps)

PropTypeDefaultDescription
colorScheme'light' | 'dark'requiredButton style per Google branding.
size'standard' | 'wide' | 'icon'requiredButton layout variant.
disabledbooleanfalseDisables press (also set when loading).
contentAlignment'center' | 'leading' | 'trailing''center'Positions the SDK button inside a wider parent.

React Native layout / a11y

From ViewProps: style, testID, accessibilityLabel, accessibilityRole, accessibilityState, collapsable, nativeID.

Recommended style.height: use GOOGLE_SIGN_IN_BUTTON_HEIGHT (48).


GoogleSignInButtonSignInBehavior

type GoogleSignInButtonSignInBehavior =
| 'credentialManager'
| 'buttonFlow'
| 'none'
ValueFlow
'credentialManager'checkPlayServices()signIn() → if noSavedCredentialFound, createAccount(). Credential Manager bottom sheet on Android.
'buttonFlow'checkPlayServices()presentExplicitSignIn(). Android account dialog (all accounts).
'none'No automatic sign-in; only onPress (unless you set success/error handlers without changing behavior — prefer explicit 'none').

GoogleSignInButtonColorScheme

type GoogleSignInButtonColorScheme = 'light' | 'dark'

GoogleSignInButtonNativeSize

type GoogleSignInButtonNativeSize = 'standard' | 'wide' | 'icon'
ValueTypical use
'standard'Default text button
'wide'Wider label layout
'icon'Icon-only

GoogleSignInButtonContentAlignment

type GoogleSignInButtonContentAlignment = 'center' | 'leading' | 'trailing'

Aligns the native button within the HybridView bounds when the parent is wider than the intrinsic button width.


GoogleSignInButtonViewProps / GoogleSignInButtonViewMethods

Low-level Nitro view contract (used by GoogleSignInButtonHost):

interface GoogleSignInButtonViewProps extends HybridViewProps {
colorScheme: GoogleSignInButtonColorScheme
size: GoogleSignInButtonNativeSize
disabled: boolean
contentAlignment?: GoogleSignInButtonContentAlignment
onPress: () => void
}

interface GoogleSignInButtonViewMethods extends HybridViewMethods {}

GoogleSignInButtonRef

Nitro hybrid ref type for hybridRef — methods match GoogleSignInButtonViewMethods (currently empty; reserved for future native commands).


useGoogleSignInFromButton

function useGoogleSignInFromButton(
options?: UseGoogleSignInFromButtonOptions
): { loading: boolean; onPress: () => Promise<void> }

UseGoogleSignInFromButtonOptions

OptionTypeDefaultDescription
behaviorGoogleSignInButtonSignInBehavior'credentialManager'Same semantics as GoogleSignInButton signInBehavior.
onSuccess(data: OneTapSuccessData) => voidSuccess callback.
onError(error: unknown) => voidError callback (error is also rethrown).
onPress() => void | Promise<void>Runs at start of press (analytics, etc.).

Return value

FieldTypeDescription
loadingbooleantrue while sign-in promise is in flight.
onPress() => Promise<void>Wire to Pressable / custom button.

Does not call presentExplicitSignIn unless behavior === 'buttonFlow'. Does not invoke onSuccess for noSavedCredentialFound or cancelled (only success).


Constants

NameValueDescription
GOOGLE_SIGN_IN_BUTTON_HEIGHT48Google branding minimum height (pt/dp).

Platform summary

APIAndroidiOS
checkPlayServicesValidates Play ServicesNo-op
signInCredential Manager (authorized accounts)Current user or restore
createAccountAll accounts (CredMan sheet)Interactive sign-in
presentExplicitSignInGetSignInWithGoogleOption dialogInteractive sign-in
signOutDisables auto sign-in semanticsGIDSignIn.signOut()
revokeAccessSame as sign-out (param ignored)disconnect
configure + autoDetectNeeds google-services.json + GradleNeeds plist WEB_CLIENT_ID + CLIENT_ID
iosClientIdIgnoredRequired via param or plist

Deprecated

/** @deprecated Use GoogleOneTapSignIn instead */
const NitroGoogleSignin = GoogleOneTapSignIn