Auth0 Home Blog Docs

Is checkSession sync or async?



auth0.js v9.7.3


we are developing a SPA, if an access token is in the local storage from a previous successful authentication, we’d like to make a silent authentication to avoid a new login UX disrupt.

For that we use checkSession and get a result:

  • KO: could not get a new token so need to login again
  • OK: do our business logic as it was a successful ‘non silent’ authentication

As checkSession has a callback for argument, we thought that checkSession is async (requires to contact the Auth0 server to provide the result?) but it’s so fast (less than 1ms) that we now feel that it’s synchronous.

If it can be both, for which cases it’s synch. and which cases it’s async.?