Current screen context data, or null if not available
Basic screen routing
import { useCurrentScreen } from '@auth0/auth0-acul-react';
const AuthFlow = () => {
const screenOptions = useCurrentScreen();
const screen = screenOptions?.screen?.name || "login-id";
switch (screen) {
case "login-id":
return <LoginIdScreen />;
case "login-password":
return <LoginPasswordScreen />;
case "mfa-otp-challenge":
return <MfaOtpChallengeScreen />;
default:
return null;
}
};
Accessing multiple properties
import { useCurrentScreen } from '@auth0/auth0-acul-react';
const CustomAuthScreen = () => {
const screenOptions = useCurrentScreen();
const organizationId = screenOptions?.organization?.id;
const errors = screenOptions?.transaction?.errors || [];
const locale = screenOptions?.transaction?.locale || 'en';
return (
<div>
{organizationId && <p>Organization: {organizationId}</p>}
{errors.map((error, i) => (
<p key={i} className="error">{error.message}</p>
))}
<p>Language: {locale}</p>
</div>
);
};
React hook that gets the current screen context and state.
This hook provides access to client configuration, organization details, screen identification, tenant settings, transaction state, and authorization parameters for building custom authentication UI.
Return Value
Returns
CurrentScreenOptionsobject with the following properties, ornullif unavailable:client- Application identifier and metadataorganization- Organization ID and metadata (for Auth0 Organizations)prompt- Current prompt name (e.g., "login", "consent", "mfa")screen- Current screen name (e.g., "login-id", "login-password", "mfa-otp-challenge")tenant- Tenant configuration including enabled localestransaction- Transaction state, errors array, and current localeuntrustedData- Authorization parameters from the client (validate before use)Key Points
screen.namefor conditional rendering of authentication screens?.) as nested properties can benulltransaction.errorsfor displaying validation errorsorganization.metadatafor organization-specific branding