MDK Logo

SignInGoogleButton

One-click Google OAuth sign-in trigger. Defaults to a full-page redirect to `$oauthBaseUrl/oauth/google`, mirroring the production MOS flow.

One-click Google OAuth sign-in trigger. Defaults to a full-page redirect to ${oauthBaseUrl}/oauth/google, mirroring the production MOS flow.

import { SignInGoogleButton } from "@tetherto/mdk-react-devkit";
PropStatusTypeDefaultDescription
iconRequiredReact.ReactNodeIcon node rendered alongside `children`.
loadingRequiredboolean | undefinedShow a spinner instead of the content and disable the button.
variantRequiredButtonVariant | undefinedVisual variant (e.g. `primary`, `secondary`, `ghost`).
sizeRequiredComponentSize | undefinedSize token (`sm`, `md`, `lg`).
fullWidthRequiredboolean | undefinedMake the button stretch to fill its container.
contentClassNameRequiredstring | undefinedClass names applied to the inner content wrapper.
iconPositionRequiredButtonIconPosition | undefinedIcon placement relative to children.
oauthBaseUrlRequiredstringBase URL of the OAuth backend (no trailing slash). Click navigates to `${oauthBaseUrl}/oauth/google`.
labelOptionalstring | undefinedOverride the visible button label.
onClickOptional(() => void) | undefinedOverride the click behaviour entirely. When set, `oauthBaseUrl` is ignored.

Usage

Single-button Google OAuth sign-in trigger. Defaults to a full-page redirect to ${oauthBaseUrl}/oauth/google. The backend issues a JWT and redirects back with ?authToken=…, which useAuthToken then persists into the session store.

Notes

  • Uses window.location.href (full-page navigation) rather than client-side routing so the OAuth callback URL is treated as an external load.
  • The backend must register the FE callback URL under the Google OAuth client. For local dev with miningos-gateway, that's http://localhost:3000/oauth/google/callback plus callbackUriUI = http://localhost:3030.

Example

/** * Runnable example for SignInGoogleButton. * * Triggers a full-page redirect to the OAuth backend. In a real app you'd * read `oauthBaseUrl` from `import.meta.env.VITE_OAUTH_BASE_URL`. */import { SignInGoogleButton } from '@tetherto/mdk-react-devkit'export const SignInGoogleButtonExample = () => (  <SignInGoogleButton oauthBaseUrl="http://localhost:3000" />)