Skip to main content
import { useStytch } from '@stytch/react';

export const Login = () => {
const stytch = useStytch();

const startOAuth = () =>
  stytch.oauth.google.start({
    login_redirect_url: '${exampleURL}/authenticate',
    signup_redirect_url: '${exampleURL}/authenticate',
    custom_scopes: [
      'https://www.googleapis.com/auth/documents.readonly',
      'https://www.googleapis.com/auth/drive.readonly',
    ],
    provider_params: {
      login_hint: 'example_hint@stytch.com',
    },
  });

return <button onClick={startOAuth}>Log in with Google</button>;
};

Documentation Index

Fetch the complete documentation index at: https://stytch.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

The oauth.$provider.start() methods start OAuth flows by redirecting the browser to one of Stytch’s oauth start endpoints. The method will also generate a PKCE code_verifier and store it in local storage on the device (See the PKCE OAuth guide for details). If your application is configured to use a custom subdomain with Stytch, it will be used automatically.
  • oauth.amazon.start()
  • oauth.apple.start()
  • oauth.bitbucket.start()
  • oauth.coinbase.start()
  • oauth.discord.start()
  • oauth.facebook.start()
  • oauth.github.start()
  • oauth.gitlab.start()
  • oauth.google.start()
  • oauth.linkedin.start()
  • oauth.microsoft.start()
  • oauth.salesforce.start()
  • oauth.slack.start()
  • oauth.twitch.start()
  • oauth.yahoo.start()

Parameters

configuration
object
Additional configuration.

Response

success
boolean
Whether the OAuth flow was started successfully.
error
Error
The error object if the OAuth flow was not started successfully.
reason
string
If error, the reason for the error. One of User Canceled, Authentication Failed, or Invalid Platform.