Skip to content

usePrepareSsoUrl

usePrepareSsoUrl(params): UseQueryResult<NoInfer<PrepareSsoReturnType>, Error>

Defined in: react/src/hook/usePrepareSsoUrl.ts:45

Hook that builds the SSO popup URL ahead of the user’s click.

Wraps `prepareSsoUrl()` in a @tanstack/react-query!useQuery | `useQuery()`, so the URL is resolved while the page is idle. Handing the result to useOpenSso() as { ssoUrl } lets the popup open in the same tick as the click, which is what keeps popup blockers out of the flow.

PrepareSsoParamsType

SSO parameters for URL generation

UseQueryResult<NoInfer<PrepareSsoReturnType>, Error>

The query wrapping the prepareSsoUrl() action, resolving to { ssoUrl }

const { data } = usePrepareSsoUrl({ metadata });
const { mutate: openSso } = useOpenSso();
<button
disabled={!data}
onClick={() => data && openSso({ ssoUrl: data.ssoUrl })}
>
Login
</button>

The URL embeds a proof-of-possession valid for 10 minutes. Past that the SSO still opens and the user still logs in — only the anonymous-to-wallet identity link is lost. On a page that can sit open for a long time, refetch rather than holding one URL indefinitely.