diff --git a/packages/react/src/components/Auth/Auth.tsx b/packages/react/src/components/Auth/Auth.tsx index 6c5234bc..a584e776 100644 --- a/packages/react/src/components/Auth/Auth.tsx +++ b/packages/react/src/components/Auth/Auth.tsx @@ -30,6 +30,7 @@ function Auth({ otpType = 'email', additionalData, children, + onViewChange, }: AuthProps): JSX.Element | null { /** * Localization support @@ -120,6 +121,14 @@ function Auth({ return () => authListener.subscription.unsubscribe() }, [view]) + useEffect(() => { + if (typeof onViewChange !== 'function') { + return; + } + + onViewChange(authView); + }, [authView]); + const emailProp: Omit = { supabaseClient, setAuthView, diff --git a/packages/react/src/types.ts b/packages/react/src/types.ts index 54ac3fb0..10b613be 100644 --- a/packages/react/src/types.ts +++ b/packages/react/src/types.ts @@ -1,4 +1,4 @@ -import { BaseAppearance, BaseAuth } from '@supabase/auth-ui-shared' +import { BaseAppearance, BaseAuth, ViewType } from '@supabase/auth-ui-shared' import { CSSProperties, ReactNode } from 'react' export interface Appearance extends BaseAppearance { @@ -17,4 +17,5 @@ export interface Appearance extends BaseAppearance { export interface Auth extends BaseAuth { children?: ReactNode appearance?: Appearance + onViewChange?: (view: ViewType) => void }