Auth0-SDK React/Redux Implemenation

I am having trouble figuring out where to store my instance of Auth0 client with React/Redux/ImmutableJS stack and where to put in state management. All examples are using context/Hooks. I was thinking about using thunk.withArugment but the problem is the createAuth0Client() resolves async. Has anyone any example of an implementation of Auth0 SDK (auth0-spa-js) with React, Redux, Thunk, ImmutableJS? I know I am probably missing something simple.

Is there a particular reason why you want to store the Auth0 client instance in your Redux store as opposed to using the hook provided by the quickstart?

Are you looking to call Auth0 client functions outside the scope of a component?

No reason to store it in redux. I have a current implementation of Auth0.js and using cookies. We are swapping that pattern for auth0-spa-js sdk. I am trying refactor all our redux pattern and actions to use the SDK methods and this is the first time I am integrating a SDK to an existing redux structure. Looking for the best approach since auth0-spa-js returns a Promise SDK.

Yes, I am calling the Auth0 Client outside the scope of my components. I decided to delay my React Render App function in index.js while the Auth0 Client is resolving and then rending the react app. While the Auth0 Client is resolving I am showing a small loading icon. If the client failed to initialize, I render a error page.

1 Like

createAuth0Client(auth0Options).then(client => {auth0Client = client; renderApp();}, error =>{ renderErrorApp();});

1 Like

Thanks a lot for sharing it with the rest of community!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.