FinBaze for Platforms

SDKs

npm install @finbaze/embed-js
import { loadFinBaze } from "@finbaze/embed-js";

const finbaze = await loadFinBaze("fb_pk_test_…", {
  fetchClientSecret: async ({ reason, previousSessionId }) => {
    const res = await fetch("/finbaze/session", {
      method: "POST",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({ previousSessionId }),
    });
    return (await res.json()).clientSecret;
  },
  appearance: { theme: "auto" },
  onError: (error) => console.error(error.code, error.message),
  onSessionExpired: (reason) => signOutOrReload(reason),
});

const calendar = finbaze.create("tax-calendar", { navigation: "external" });
calendar.on("navigate", ({ intent }) => router.push(toRoute(intent)));
calendar.mount("#finbaze");

Or use the script tag: <script src="https://embed.finbaze.com/v1/embed.js"></script> exposes window.FinBaze.load(...).

fetchClientSecret

Called on mount and before every refresh. It must return a new client secret each time. reason is "initial", "refresh", "revoked" (the session was revoked; mint a fresh chain) or "error" (the last attempt failed). Pass previousSessionId to createEmbedSession.

Instance#

Method
create(name, options)A component; call mount(target) on it
update({ appearance, locale })Restyle or switch language live
logout()Drop the token and destroy every component
destroy()Remove the controller and everything it mounted

Component#

Method
mount(target) / unmount() / destroy()Lifecycle
update(options)Change options without remounting
navigate(intent)Move a mounted component
on(event, handler)Returns an unsubscribe function

See errors for the codes in FinBazeEmbedError.code.