Next.js Discord

Discord Forum

SearchBar Functionality

Unanswered
Magyar agár posted this in #help-forum
Open in Discord
Magyar agárOP
i have this searchbar how do i sezrch for my products

9 Replies

Blue horntail woodwasp
where you product data from?
is it from external API? or something else?
Magyar agárOP
yes it is an external API
i have an ecomerce that uses API , i have the admin Dashbord than i have the store
in the store i want to search the products
Can you help me ?
Blue horntail woodwasp
maybe you want to follow this tutorial first to understand how nextjs works?
https://nextjs.org/learn?utm_source=next-site&utm_medium=homepage-cta&utm_campaign=home
I saw your code you did not implement any fetch data yet.
This a few step to guide :
1. try to Fetch data product from your API (you can use fetch inside your page using fetch() api.
2. try to Fetch data product with some keyword from your API.
3. get the input values, you can use state.
4. put that state values to your fetch() on every time you want to search.
Giant panda
A search should be implemented server-side. Here's our FAQ entry that shows exactly that: https://nextjs-faq.com/sharing-client-side-state-with-server-components