diff --git a/packages/react/src/components/Auth/Auth.tsx b/packages/react/src/components/Auth/Auth.tsx index e1709699..1a0076bc 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, passwordLimit, + onViewChange, children, }: AuthProps): JSX.Element | null { /** @@ -42,6 +43,12 @@ function Auth({ const [defaultEmail, setDefaultEmail] = useState('') const [defaultPassword, setDefaultPassword] = useState('') + useEffect(() => { + if (onViewChange) { + onViewChange(authView) + } + }, [authView, onViewChange]) + /** * Simple boolean to detect if authView 'sign_in' or 'sign_up' or 'magic_link' is used * 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 }