Getting user outside of auth0-react sdk

Hi! I need to acces user from useAuth0 hook outside of my react components. I found a related gist for solution to use getAccessTokenSilently here and wonder is it safe to do so with user?

export const deferredUser = (() => {
  const props = {};
  // @ts-ignore
  props.promise = new Promise((resolve) => (props.defer = resolve));
  return props;
})();

export const getUser = async () => {
  // @ts-ignore
  const user = await deferredUser.promise;
  return user;
};

<Auth0Provider
  domain={import.meta.env.VITE_API_AUTH0_DOMAIN}
  clientId={import.meta.env.VITE_AUTH0_CLIENT_ID}
  onRedirectCallback={onRedirectCallback}
  authorizationParams={{
    redirect_uri: window.location.origin,
  }}
>
  <Auth0Context.Consumer>
    {({ user }: Auth0ContextInterface) => {
      if (user) {
        // @ts-ignore
        deferredUser.defer(user);
      }
      return <Outlet />;
    }}
  </Auth0Context.Consumer>
</Auth0Provider>