Skip to content

openSso

openSso(client, inputArgs): Promise<OpenSsoReturnType>

Defined in: actions/openSso.ts:71

Function used to open the SSO

FrakClient

The current Frak Client

OpenSsoArgsType

Promise<OpenSsoReturnType>

Two SSO flow modes:

Redirect Mode (openInSameWindow: true):

  • Wallet generates URL and triggers redirect
  • Used when redirectUrl is provided

Popup Mode (openInSameWindow: false/omitted):

  • SDK generates URL client-side (or uses provided ssoPopupUrl)
  • Opens the popup, then waits for SSO completion via postMessage

Pass { ssoUrl } from `prepareSsoUrl()` to open the popup without awaiting anything first — see the popup-blocker note below.

First we build the sso metadata

// Build the metadata
const metadata: SsoMetadata = {
logoUrl: "https://my-app.com/logo.png",
homepageLink: "https://my-app.com",
};

Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL

Popup (default)
// Opens in popup, SDK generates URL automatically
await openSso(frakConfig, {
directExit: true,
metadata,
});
Redirect
// Opens in same window with redirect
await openSso(frakConfig, {
redirectUrl: "https://my-app.com/frak-sso",
metadata,
openInSameWindow: true,
});
Pre-built URL
// Prepared ahead of the click, so the popup opens synchronously
const { ssoUrl } = await prepareSsoUrl(frakConfig, { metadata });
// ...later, directly in the click handler:
await openSso(frakConfig, { ssoUrl });
Custom popup URL
// Advanced: provide custom SSO URL
const { ssoUrl } = await prepareSso(frakConfig, { metadata });
await openSso(frakConfig, {
metadata,
ssoPopupUrl: `${ssoUrl}&custom=param`,
});