Reputation: 11
Has anyone made a react website with static data that does not have a backend to store information, but needs to add a query/search functionality in the front end that can fetch information(a specific keyword that can be present on multiple pages of the app) from the entire app?
What I am looking for is, an option to store the data and made a query from there without implementing a backend from scratch. Is that possible? From my research so far, what I have found so far is I need to store all the information to some storage services like Firebase or Firestore and need to retrieve data from the entire app and only thenI can implement search functionality using third-party apps like typesense or algolia. But did not find any specific example based on that. I am a beginner in react, so any kind of help would be highly appreciated.
Upvotes: 0
Views: 533
Reputation: 1121
You can use Local Storage API to save data on the frontend. You can store a JSON object as string in the localstorage using
localStorage.setItem('my-key', jsonObjectString);
Later you can retrieve the object using
const textFromStorage = localStorage.getItem('my-key');
let jsonObject = JSON.parse(textFromStorage)
// Now you can do your query here
Upvotes: 1