Skip to main content

useFlow()

You're reading Identity & Access Management 7.0.0. The newest release is 7.3.0, and Cloud has the newest features. Go to the newest release

useFlow() returns the UI state of the embedded authentication flows of the WSO2 Identity Server Nuxt SDK (@asgardeo/nuxt), such as the current step, title, and messages.

Overview​

<AsgardeoSignIn> and <AsgardeoSignUp> use this state to render their headings and messages. Use useFlow() when you build custom UI around those components. The module auto-imports useFlow().

note

Call useFlow() only in components that render inside <AsgardeoRoot>. Otherwise, it throws an error.

Usage​

<script setup lang="ts">
const { title, messages, removeMessage } = useFlow();
</script>

<template>
<h2>{{ title }}</h2>
<div v-for="message in messages" :key="message.id">
{{ message.message }}
<button v-if="message.dismissible" @click="removeMessage(message.id)">Dismiss</button>
</div>
</template>

API​

useFlow() returns the following values.

State​

PropertyTypeDescription
currentStepReadonly<Ref<FlowStep>>The current step, with id, type, title, and optional subtitle, canGoBack, and metadata. type is one of 'signin', 'signup', 'organization-signin', 'forgot-password', 'reset-password', 'verify-email', or 'mfa'.
titleReadonly<Ref<string>>The title of the current step.
subtitleReadonly<Ref<string | undefined>>The subtitle of the current step.
messagesReadonly<Ref<FlowMessage[]>>Messages to show. Each has message, type ('success', 'error', 'warning', or 'info'), and optional id and dismissible.
errorReadonly<Ref<string | null>>The current error.
isLoadingReadonly<Ref<boolean>>Whether the flow is loading.
showBackButtonReadonly<Ref<boolean>>Whether to show a back button.
onGoBackReadonly<Ref<(() => void) | undefined>>The handler of the back button.

Methods​

MethodDescription
navigateToFlow(flowType, options?)Moves to a flow step of the given type. options can set title, subtitle, and metadata.
setCurrentStep(step)Sets the current step.
setTitle(title) / setSubtitle(subtitle?)Sets the title or subtitle.
addMessage(message) / removeMessage(id) / clearMessages()Adds, removes, or clears messages.
setError(error)Sets or clears the error.
setIsLoading(loading)Sets the loading state.
setShowBackButton(show) / setOnGoBack(callback?)Controls the back button.
reset()Resets the flow state.

Was this page helpful?