Adding Search Feature in Server Components | NextJs 13

  Рет қаралды 19,187

Hamed Bahram

Hamed Bahram

Күн бұрын

Пікірлер: 86
@Kai-cz7wf
@Kai-cz7wf 4 ай бұрын
Am really glad I clicked this video, at first I thought i have to state management for all this stuff but you make it really simple and awesome and exactly same what I want to make. Thnx a lot
@hamedbahram
@hamedbahram 4 ай бұрын
Glad it was helpful!
@Kai-cz7wf
@Kai-cz7wf 4 ай бұрын
@@hamedbahram there is a problem i found, I also have some button on the page redirecting to another page but they all came back ('/movies") whenever I click them, Is there any solution??
@MranZupljanin
@MranZupljanin 11 ай бұрын
what a hidden gem of a channel, ur explanations are magnificent.. great job
@hamedbahram
@hamedbahram 11 ай бұрын
Thanks! glad you think so!
@eshw23
@eshw23 Жыл бұрын
Dude I cant believe youtube didnt recommend your channel to me wow glad I found it, was looking for more basic technical videos on concepts we need to master instead of 5 hour long project tutorials. These helps me work on my own projects
@hamedbahram
@hamedbahram Жыл бұрын
Glad to hear that! Welcome to the channel. I appreciate your comment.
@heysahilsingh
@heysahilsingh 8 ай бұрын
Same feeling ❤
@ogbillity
@ogbillity Жыл бұрын
Excellent tutorial. Thank you so much.
@hamedbahram
@hamedbahram Жыл бұрын
Glad it was helpful Peter!
@darawan_omar
@darawan_omar 4 ай бұрын
I don't know what to say or describe you. You are always the best ❤❤
@hamedbahram
@hamedbahram 4 ай бұрын
Thank you so much 😀
@eliuddyn
@eliuddyn Жыл бұрын
Amazing Tutorial 🔥🔥
@hamedbahram
@hamedbahram Жыл бұрын
Thanks 🔥
@benjimosso
@benjimosso 3 ай бұрын
Man, you are amazing! Thank you so much!!
@hamedbahram
@hamedbahram 3 ай бұрын
You're welcome! Glad it helped.
@mariocesena2277
@mariocesena2277 5 ай бұрын
Awesome tutorial! 👌🏼👌🏼
@hamedbahram
@hamedbahram 5 ай бұрын
Thank you 🙌
@juanferrer5885
@juanferrer5885 Жыл бұрын
Awesome tutorial. A tutorial of testing in App router would be great
@hamedbahram
@hamedbahram Жыл бұрын
Thank you! Great suggestion by the way.
@peteronyegbule7207
@peteronyegbule7207 4 ай бұрын
you saved me from 4 days of no success thank you so much
@hamedbahram
@hamedbahram 4 ай бұрын
Glad I could help
@rishuscript
@rishuscript 6 ай бұрын
Underrated channel 😢 Lots of love to your channel ❤
@hamedbahram
@hamedbahram 6 ай бұрын
Thank you! I appreciate that!
@movietime8403
@movietime8403 3 ай бұрын
Thank you :), it was really useful you saved me from the bugs which i have been working on 2 days.
@hamedbahram
@hamedbahram 3 ай бұрын
Glad it helped!
@bhuvicodes
@bhuvicodes 6 ай бұрын
What a great tutorial ❤
@hamedbahram
@hamedbahram 6 ай бұрын
Glad you think so!
@user-ck8vg9bd6v
@user-ck8vg9bd6v 4 ай бұрын
thank you brother for that video
@hamedbahram
@hamedbahram 4 ай бұрын
My pleasure!
@mamunahmed8113
@mamunahmed8113 Жыл бұрын
Big fan from Bangladesh❤❤❤
@hamedbahram
@hamedbahram Жыл бұрын
Welcome to the channel!
@mousaahmed6689
@mousaahmed6689 6 ай бұрын
absolutely magnificent
@hamedbahram
@hamedbahram 6 ай бұрын
Appreciate it!
@jordanrodrigues1824
@jordanrodrigues1824 11 ай бұрын
Superb!
@hamedbahram
@hamedbahram 11 ай бұрын
Thank you! Cheers!
@pamcls
@pamcls 3 ай бұрын
Amazing content, as always. You're the man!!!👏 Now, I have a problem with this approach, dunno, if you can help: Since you know Prismic, I'll expose the real scenario: I have a dynamic Page server component (let's say: [page]) and I have multiple slices in it. One of them it's an `ArticleCategory` slice (server component) that fetches a list of articles of a specific category and in that slice, as child component, I have a client component that handles the searchTerm. All fine and using the same example you're showing in the video, however, I get a 500 error when accessing a page with that slice because I am using generateStaticParams on that `Page` component to get all the documents from Prismic. The error is known: "Static to Dynamic Error" and there's a fix for regular scenarios, advised by nextjs, just turn your page into dynamic (If I remove the `generateStaticParams`) it works but that defeats the whole purpose of having static regeneration. I know this is farfetched but maybe you've a solution for this 🙏😅 Thanks in advance for your help
@hamedbahram
@hamedbahram 3 ай бұрын
Thank you! I've had a similar problem before with the static generation and deleting the `.next` folder and restarting the dev server or rebuilding the project solves the problem most of the time. But beyond that I'm not sure what specifically might cause this error in your implementation.
@user-ny9em7sy7f
@user-ny9em7sy7f 8 ай бұрын
Followed your steps,everything working excepts useEffect in searchBar component, on refresh page={number} is deleted
@hamedbahram
@hamedbahram 8 ай бұрын
Compare your code to mine (link in description) and see what you're doing differently.
@user-ny9em7sy7f
@user-ny9em7sy7f 8 ай бұрын
did it but still the same... @@hamedbahram
@ahmadnehal
@ahmadnehal 2 ай бұрын
In my case, it was due to React's Strict Mode that you can turn off in next.config.js.
@mohammadmalek5042
@mohammadmalek5042 11 ай бұрын
Thank you ❤
@hamedbahram
@hamedbahram 11 ай бұрын
Welcome!
@oluwafemifaleye6845
@oluwafemifaleye6845 Жыл бұрын
Thank you so much
@hamedbahram
@hamedbahram Жыл бұрын
Anytime!
@FGA-47
@FGA-47 7 ай бұрын
Thanks alot
@hamedbahram
@hamedbahram 7 ай бұрын
Happy to help!
@aymenbachiri-yh2hd
@aymenbachiri-yh2hd Ай бұрын
Thanks
@hamedbahram
@hamedbahram Ай бұрын
Welcome!
@zaidsameer
@zaidsameer Жыл бұрын
Thanks for the great tutorials you provided, What If I have more than one param each passing the params values to a parent (server component) page and i want to delete one of the params?
@hamedbahram
@hamedbahram Жыл бұрын
I'm not sure if I understand the question correctly. We are setting two different params here, one for the search term, and the other for the page number from different components.
@user-yq3if2mi5h
@user-yq3if2mi5h 9 ай бұрын
Hello Hamed! Could you please show us how to make multi category filter system in addition to pagination and search using server components with URL? Thank you in advance!
@hamedbahram
@hamedbahram 9 ай бұрын
That's a good idea, I'll have that in mind. Thanks.
@UWalexs
@UWalexs 5 ай бұрын
for me, useEffect is rendered multiple times and that initial "first render" if block is bypassed and I lose the page query param upon refreshing the page. When config is set to strictMode: "false", then this logic works. Any ideas? 🤔
@hamedbahram
@hamedbahram 5 ай бұрын
It shouldn't be like that, clone and compare my code to see what you're doing differently!
@ahmadnehal
@ahmadnehal 2 ай бұрын
In my case, it was due to React's Strict Mode that you can turn off in next.config.js.
@StephenRayner
@StephenRayner Жыл бұрын
Do a video on event driven architecture in NextJS 13 with Inngest 🎉
@hamedbahram
@hamedbahram Жыл бұрын
Thanks for the suggestion, I like that!
@adeniyitaofik3832
@adeniyitaofik3832 6 ай бұрын
Hello what if you have other query in the url alreay how do you remove just the search from the url query params without affecting others
@hamedbahram
@hamedbahram 6 ай бұрын
Good question, you'd have to get all query parameter and only rewrite the `search`
@0xtz_
@0xtz_ 11 ай бұрын
Amazing 👏, I'm using a model, I have a form to select a user by searching.... any other ideas to implement this without setting the url ? Please
@hamedbahram
@hamedbahram 11 ай бұрын
You can use server actions as well, if you look at the infinite scrolling video where I use a server action to fetch data from the server but also from the client. Other than that you can use the good old client side fetching.
@0xtz_
@0xtz_ 11 ай бұрын
@@hamedbahram thanks man
@hamedbahram
@hamedbahram 11 ай бұрын
@@0xtz_ Anytime!
@christophercaldwell6641
@christophercaldwell6641 5 ай бұрын
What would you suggest if you wanted to show a loading skeleton of movies while the search was running? It looks instant, but what if you added an artificial 2-3 second delay on getMovies? Do you know how to go about showing the static content of movies while the server waits for the movies to load?
@christophercaldwell6641
@christophercaldwell6641 5 ай бұрын
I just saw your other video where you make a loading skeleton lol. Watching it now! Oops.
@hamedbahram
@hamedbahram 5 ай бұрын
There you go :)
@christophercaldwell6641
@christophercaldwell6641 5 ай бұрын
@@hamedbahram Great video thank you. Have you used partial prerendering? Adding the key did not solve the stale issue when PPR was enabled. Not your problem, ofc. It works just fine without PPR enabled. Wondering if you have used it at all and did the same thing in the video, just with PPR
@hamedbahram
@hamedbahram 5 ай бұрын
@@christophercaldwell6641 Haven't tried it with this particular example. But I'll have a video on partial pre-rendering soon.
@christophercaldwell6641
@christophercaldwell6641 5 ай бұрын
@@hamedbahram oh okay, cool. I’ve been stuck for a few days, I haven’t been able to find any solution. I tried all of the things you mentioned, router refresh, keys, etc. In my experience when you navigate, the route doesn’t change until the fresh data has been loaded and then it abruptly changes to the new stuff. Another thing of note is that this worked as expected for me in local development, but hosted on Vercel did not. I’d love to see a video on this, it’s frustrating and I’m close to using a client side data fetching pattern to get around it. Not ideal!
@aravind_k28
@aravind_k28 Жыл бұрын
Amazing tutorial ❤. But one doubt, even if you use search params as state, it will do server rendering but it won't show any loader right? And also it will take some noticable time to get the results and render them. loader.tsx file also won't help... So which method should we use client or server components? Hoping for a response... Thank you!
@hamedbahram
@hamedbahram Жыл бұрын
Thank you. You can use either one, I prefer server components, because it eliminates the need to create an API layer, also it's faster as it ships less JS to the browser, it can also benefit from NextJs cache. The loading UI is not ideal as it won't trigger since the route doesn't change.
@aravind_k28
@aravind_k28 Жыл бұрын
@@hamedbahram Thank you!
@aravind_k28
@aravind_k28 Жыл бұрын
@@hamedbahram but user won't see any feedback like loader while the data is being fetched, what can we do in that case? Isnt that a bad ux?
@hamedbahram
@hamedbahram Жыл бұрын
@@aravind_k28 Agreed! we need a loading inidcator, I'm thinking to pass the promise to await it in a suspense component... I'd have to think about this. Let me know if you could come up with a solition in the mean time.
@aravind_k28
@aravind_k28 Жыл бұрын
@@hamedbahram I tried that approach. It won't work as expected if you change query params. I also tried loading.tsx, no hope. But even if we add loading.tsx or suspense, we will loose SEO, because the crawlers will see loading icon only. Currently I don't know how to achieve the exact balance between SEO and decent UX... 🥲
@generalwill10
@generalwill10 Жыл бұрын
I’d like to see an example like this but querying an API…anyone know of a good resource that shows that?🧐
@hamedbahram
@hamedbahram Жыл бұрын
Do you mean querying an API from a client component?
@generalwill10
@generalwill10 Жыл бұрын
@@hamedbahram I suppose in your example yes. I’m transposing an app I made using an api from Next 13 to Next 13.4 where the App router became stable. I want to add a search bar to my app to query the api and then receive whatever they query back to them.
@hamedbahram
@hamedbahram Жыл бұрын
@@generalwill10 Ok great! and what part is stopping you?
Loading Skeleton for Search & Pagination in NextJs 13 Movie App
23:15
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 10 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН
Next 14 + React Query COMBO with Server Actions and RSC
9:49
developedbyed
Рет қаралды 96 М.
Add Search in Next.js with Server Actions
19:27
Colby Fayock
Рет қаралды 2,5 М.
Why I Still Use React Query with Next 14
11:28
developedbyed
Рет қаралды 58 М.
Next.js Search Filter Tutorial For Beginners
17:52
Coding with Basir
Рет қаралды 31 М.
Server vs client components in NextJs 13 - When to use which
34:07
Hamed Bahram
Рет қаралды 33 М.
Build a Search Bar with Next.js and Prisma (Search API endpoint)
40:22
Nested Layouts in NextJs 13 Using Route Groups
13:33
Hamed Bahram
Рет қаралды 13 М.