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

113
Views
Calling initializeApp on refresh deleting the auth token stored in localstorage

I'm using firebase to build a browser based app. I'm having this piece of code that is called when the page loads,

this._app = initializeApp({
  apiKey: this._apiKey,
  authDomain: `${this._projectId}.firebaseapp.com`,
  projectId: this._projectId,
  storageBucket: `${this._projectId}.appspot.com`,
  messagingSenderId: this._senderId,
  appId: this._appId
});

this._db = getFirestore(this._app);

Then I've a login method that uses browserLocalPersistence as below,

async login(email, password) {
  const auth = getAuth();
  await setPersistence(auth, browserLocalPersistence);
  return signInWithEmailAndPassword(auth, email, password);
}

When I login first I see the token is successfully stored in localstorage. On refreshing the page I see the token is removed from localstorage and I think this is happening due to initializeApp. How can I keep the token persistent in localstorage?

about 4 years ago · Juan Pablo Isaza
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!