# 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()\`](/developers/references/core-sdk/actions/functions/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.

## Parameters

### params

`PrepareSsoParamsType`

SSO parameters for URL generation

## Returns

`UseQueryResult`\<`NoInfer`\<`PrepareSsoReturnType`\>, `Error`\>

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

## Example

```tsx
const { data } = usePrepareSsoUrl({ metadata });
const { mutate: openSso } = useOpenSso();

<button
    disabled={!data}
    onClick={() => data && openSso({ ssoUrl: data.ssoUrl })}
>
    Login
</button>
```

## Remarks

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.

## See

 - [\`prepareSsoUrl()\`](/developers/references/core-sdk/actions/functions/preparessourl/) for the underlying action
 - [\`useOpenSso()\`](/developers/references/react-sdk/functions/useopensso/) for opening the prepared URL