Fetching Data for Search Bar Homepage

So I'm trying to make a website with a homepage that has a search bar along with pre-computed data shown. The data is fetched through an API I would write in next.js. I want the search bar to begin showing suggestions as the user types. Assuming this is a clothes website, the search bar is used to find clothes. My question is how should I approach implementing the search bar? How do I maintain SEO? One way I'm thinking is using SSG and have all the possible clothes pre-loaded to the client? Any help is appreciated thanks!
1 Reply
Xaohs
Xaohs2y ago
So I'm making a search bar as well right now. The way I'm thinking about doing this is having a variety of SSG products, which will get filtered through while the user types, and after the user stops typing (meaning, a 1-2 second delay after no input), the server will fetch new data and filter through that data, to show the actual list of products. While the user is typing you could show a spinner to indicate that new data is being fetched I'm not sure if this is the best way though. Just the way I'm thinking about doing it. If anybody has input on this, please hop in - Interested what other people's takes on this is.
Want results from more Discord servers?
Add your server