useLastUsedMethod()
function useLastUsedMethod(): undefined | LastUsedMethod
Returns the login method the user chose last time on this device, for the current login screen:
- On any screen that carries an identifier, including a form that shows the entered identifier again after an error, only the method last used with that identifier.
- On
select_methodwithout an identifier, nothing. - Otherwise, the last method used on this device. This covers an empty first screen, in both identifier-first and one-step logins.
Returns
undefined | LastUsedMethod
The last used method. undefined while it loads, when there is none, when show_last_used_method is off, outside login flows,
and on second factor screens.
Example
import { useLastUsedMethod } from "@ory/elements-react"
function LastUsedHint() {
const lastUsed = useLastUsedMethod()
if (lastUsed?.method !== "oidc") {
return null
}
return <p>You signed in with {lastUsed.provider} last time.</p>
}