Customize the widget

Optional. Callbacks, behavior and styles of the login button.

Customize the widget

Your apiKey, and authEndpoint if you change it, go in config (Configure the widget). The components only take behavior, callback and styling props.

Props are documented with their React names; the same surface exists in every binding with the framework's idiom:

  • Vue: same props in kebab-case (:on-success, :dropdown-btn-size, :show-dropdown-when-connected, …).
  • Angular: styling and behavior props are inputs ([dropdownBtnSize], [showDropdownWhenConnected], …) and callbacks are outputs: (success), (errored) and (loggedOut) in FlowBlockAuth, (linked) and (errored) in LinkBlockAuth.

FlowBlockAuth: callbacks

  • onSuccess (function): called after a successful login, with the user's address.
  • onError (function): called when the login fails or the user closes the login window.
  • onLogout (function): called after the user logs out from the profile menu.

FlowBlockAuth: behavior

  • showDropdownWhenConnected (boolean): shows the profile menu when the user is signed in (default: true).
  • isInsideModal (boolean): set it to true when the button is inside your own modal (default: false).
  • containerRef (ref): the modal's container, used with isInsideModal to detect clicks outside.
  • buttonText (string): label of the sign-in button.

FlowBlockAuth: when your backend handles the login

With the backend routes you don't need these props. Use them only if your page already knows the user or your backend redeems the code its own way. In Angular both are inputs: [user] and [onAuthCode].

  • user (object | null): the signed-in user as your backend knows it ({ address, did, roles }), or null if nobody is signed in. With it, the widget shows that user and doesn't ask /me when the page loads, for example when your server already renders the user.
  • onAuthCode (function): receives { code, codeVerifier, redirectUri } after the login instead of sending it to /code. Send it to your backend, redeem it there and return the user. Unless you also set authEndpoint, the widget then doesn't call /me or /logout nor check the session: close your session in onLogout.

FlowBlockAuth: styling

  • btnClassNames
  • btnTextClassNames
  • dropdownBtnSize (string): "xs", "small", "base" or "large" (default: "small").
  • dropdownBtnBgClassNames
  • dropdownBtnTextColorClassNames
  • dropdownBtnBorderClassNames
  • dropdownHeight (number)
  • additionalDropdownItems (array): extra options for the profile menu. Each item is { onClick, text, firstIcon?, disabled? }, where text is a string or a map per language ({ es, en }).

LinkBlockAuth

The account linking button. It hides itself once the user is linked.

  • onLinked (function): called after the account is linked.
  • onError (function): called with the reason: already_linked, not_signed_in or failed.
  • buttonText (string): label of the button.
  • btnClassNames, btnTextClassNames: same as in FlowBlockAuth.