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

167
Views
Firestore React get document by URL

I have a question about the operation that can be used with firestore

I have a table displaying a list of documents. (url: localhost/dashboard/users)

When I click on a document in the list, I want to be redirected to a details page. (url: localhost/dashboard/user/1)

Except that with firestore, my url is represented in this form: (url: localhost/dashboard/user/MuVsCLALiQPZuxnV3yyQ)

How do you get a details page with a "clean" URL.

Knowing that I want to be able to display the details of a user by going through the complete url and without necessarily going through the list

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If by "clean" you mean integers or shorter UIDs then you'll can store a field in user's Firestore document e.g. {shortUid: 1} (or set that short UID as document ID at first place) and then query based on the ID:

const userId = getIdFromURL();

const user = await getDocs(collection(db, "users"), where("shortUid", "==", userId))

Using sequential IDs is not recommended with NoSQL databases like Firestore so do checkout Firestore Best Practices

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