KindeK
Kinde3y ago
1 reply
Martin

Accessing appState

https://kinde.com/docs/developer-tools/react-sdk/#persisting-application-state gives an example for how to handle redirecting back to the page a user was on before they clicked the login button.

However, as per https://discord.com/channels/1070212618549219328/1161828367511859291/threads/1174693165748461628 I'm currently redirecting the user to a special page which handles making an API call to map them into an organisation based on some business logic. This means I want to wait until that API call completes before I redirect back to the original URL. To enable this I'm currently using a big hack:
      onRedirectCallback={(_user, appState) => {
        if (appState?.redirectTo) {
          // TODO: This is a hack to get around the fact that we don't have access to the
          // kinde_redirect_to in a persistant way. We need to set this in index.jsx and
          // read it in AssignOrg.tsx.
          window["kinde_redirect_to"] = appState?.redirectTo;
        }
      }}

Is there a better way of doing this? I couldn't see anything returned from useKindeAuth() which exposed the appState.
Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Kinde Docs
Our developer tools provide everything you need to get started with Kinde.
React SDK - Developer tools - Help center
Was this page helpful?