Is to possible to use appState outside of onRedirectCallback?

I have been using auth0-react in my project for the past six months and recently got into a possible limitation of the library.

My login flow is as follows

The requirement is that once the user logins, if he presses the back button the callback page will appear and the user should be redirected again. Because accessing the callback page doesn’t trigger the onRedirectCallback function , I moved the redirection logic to the pertinent component.

const Callback = ()=>{
  useEffect(()=>{
   // redirectLogic
  },[])  
}

However, now I can’t redirect users to protected pages if they are not logged in (for example, if they enter /tasks on the url bar and login, they should be redirected to /tasks). I don’t have access to the appState.returnTo aside from onRedirectCallback so there is no way to redirect to pages with protected routes.

On the other hand, if I move all the logic to Auth0Provider , clicking the back button won’t trigger onRedirectCallback so there would be no redirection.

Is there any workaround for this? I see you can do it on next-js but there seems to be an inherent limitation of the SPA library for this use case (which kind of makes sense because it does all the encryption of the state for you).