Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
Nuxt.js loginWith Auth0 delayed redirect

I have the following setup with Auth0 & Nuxt.js. Somehow after loginWith, the page still continues to render for a brief moment before redirecting to Auth0's login page. The promise returned from loginWith is undefined, which makes blocking on it impossible. Is there a way to immediately proceed with Auth0 login without rendering the page first?

if (!this.$auth.loggedIn) {
  await this.$auth.loginWith("auth0");
}
const user = this.$auth.user;
// Operations using user information below //
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

First of all you should not block rendering until some asynchronous operation complete. Basically the async call to a function decorated with "await" is required to let the UI thread to do its job. Instead of blocking rendering you should display some useful information for the user, at least some message that describes the process being performed: "Authorizing..." or something like this.

To resolve you problem you can declare some boolean variable in your component (or in your vuex store) that is set to false until user is authorized. By checking this value in your html template you can prevent showing page content until browser is redirected to auth page.

data() {
  return {
    isAuthorized: false;
  }
}

// your code
if (!this.$auth.loggedIn) {
  await this.$auth.loginWith("auth0");
} else {
  this.isAuthorized = true;
}

// process user information
over 4 years ago · Santiago Trujillo Report

0

The 'await this.$auth.loginWith("auth0");' is causing the breif moment of delay. This is the time required to verify if the current session is active. This can be handled by adding something like a loading page.

showLoadingPage(); // display a fullscreen loading animation or text
if (!this.$auth.loggedIn) {
  await this.$auth.loginWith("auth0");
}
hideLoadingPage(); // hide the loading animation after the await completes

const user = this.$auth.user;
// Operations using user information below //
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!