mav91
mav91

Reputation: 175

React Firestore how to create a unique url when posting document to firestore

Not sure where to start on this one, so here goes.

After creating a document in Firestore by POSTing data the user inputs in my React application state, how can I create a unique URL that a user can visit to GET/view that data?

For example:

https://myreactwebsite.com/new-document/

I need to ensure that a unique URL exists in my website index, so that not only can a user visit, but it can be indexed by Google for SEO.

My React application is hosted on Firebase as well as using Firestore for the database.

Upvotes: 1

Views: 350

Answers (1)

Abe
Abe

Reputation: 441

Firestore is a NoSQL Document database (Much like MongoDB if you're familiar with it). They both implement some form of document ID in each document. That could be leveraged in creating a unique route in your use case.

I would create a route such as /profile/:id in your react app, that when you visit it you make a call to your backend requesting that profile and then use the response from that request to fill in the data.

I would try to describe it here but in all honesty, this page does a much better job than I could in one short SO post

Upvotes: 1

Related Questions