Loading Skeleton for Search & Pagination in NextJs 13 Movie App

  Рет қаралды 12,590

Hamed Bahram

Hamed Bahram

Күн бұрын

In this video, we'll use Suspense to add a loading skeleton to our movie app during search and pagination. We'll also learn about the Router cache and how to invalidate it to show our pending UI.
👉🏼 The Ultimate NextJs Course
🔗 www.hamedbahram.io/courses/ne...
👉🏼 Project source code
🔗 github.com/HamedBahram/next-p...
Chapters
0:00 Intro
1:26 Project setup
2:30 Extract movies into a component
4:40 Add Suspense
7:10 Invalidate the Router cache
14:30 Add key to page component
16:15 Add loading skeleton
17:30 Add the Await component
21:46 Outro

Пікірлер: 46
@AdilChehabiChkilel
@AdilChehabiChkilel 11 ай бұрын
Thanks a lot Hamed, I struggled with that and gave up after hours of searching and reading the doc. Your way of explaining complex concepts is the best I've ever seen, in every tutorial I found you answering all the questions that are in my head 👍.
@hamedbahram
@hamedbahram 11 ай бұрын
Glad to hear that! Appreciate your comment.
@user-ji9mk2gd6i
@user-ji9mk2gd6i 9 ай бұрын
wow it's really to help full i spend hour's and hours but you give solution within 10 minutes thank's a lot , you make video on real problems of work issue that's really very helpful to us
@hamedbahram
@hamedbahram 9 ай бұрын
You're welcome. I'm glad to hear that.
@amir25370
@amir25370 7 ай бұрын
What a perfect tutorial. Amazing. I wish i knew your channel earlier
@hamedbahram
@hamedbahram 7 ай бұрын
Glad it was helpful! Welcome to the channel.
@ts3798
@ts3798 2 ай бұрын
Very helpful, thanks Hamed.
@hamedbahram
@hamedbahram 2 ай бұрын
My pleasure!
@nomadmack
@nomadmack 11 ай бұрын
Great video, thanks a lot!
@hamedbahram
@hamedbahram 11 ай бұрын
Glad you liked it!
@NOTHING-en2ue
@NOTHING-en2ue 11 ай бұрын
very well tutorial, thanks a lot ❤
@hamedbahram
@hamedbahram 11 ай бұрын
You're welcome 😊
@germain1984
@germain1984 11 ай бұрын
Love your videos! Learned a lot from your section on router caching. Would be amazing if you could make one video summarizing all of the Caching behavior in Next.js 13.4+ as I believe that is the single biggest headache in the new Next.js
@hamedbahram
@hamedbahram 11 ай бұрын
Great suggestion! Glad you found it helpful.
@eliuddyn
@eliuddyn 11 ай бұрын
Amazing Bro 🔥🔥
@hamedbahram
@hamedbahram 11 ай бұрын
Thanks 🔥
@ekimdev7622
@ekimdev7622 9 ай бұрын
Thank you so much for the information thats really useful. Can i ask a question here, since we are "disabling" client cache in browser by adding key, it will not affect the server cache right if we send request with native fetch api and cache set to "force-cache" ?
@hamedbahram
@hamedbahram 9 ай бұрын
You're welcome! That's right it won't effect the fetch deduplication, and it won't disable the client cache entirely either, it just re-renders the component with the key prop.
@ekimdev7622
@ekimdev7622 9 ай бұрын
Thank you so much Hamed, that was really hard to discover it to me :D !@@hamedbahram
@ekimdev7622
@ekimdev7622 9 ай бұрын
That might me an interesting and unnecessary thing but , is there any chance like to deploy next project to vercel with the server cache we got in local ? :D@@hamedbahram
@hey.............
@hey............. 11 ай бұрын
Hey, really informative. One question though, lets say i have 3 api calls on my page component. I want one call to be revalidated after every 45 seconds and want to pass the result of this call to 2 other calls on this page. For these 2 calls i want to disable caching and as i am using next.js extended fetch api. I set cache:no-store. Now if i switch between pages, i see my data is stale. I will try setting key attribute, but if i set key attribute does caching works for my first api call?
@hamedbahram
@hamedbahram 11 ай бұрын
Interesting scenario here 🤔 I'd have to see the code for this to know how you're implementing all these requests. Use the key and let me know how it goes.
@hey.............
@hey............. 11 ай бұрын
Key attribute doesn't seem to work
@hamedbahram
@hamedbahram 11 ай бұрын
@@hey............. If you turn the whole page or all your fetch requests to dynamic, does it solve the problem?
@zhiven7484
@zhiven7484 7 ай бұрын
Nice Video!! This is an optimistic situation, but how to handle error if the server action data fetching return something error?
@hamedbahram
@hamedbahram 7 ай бұрын
What this video for handing errors → kzfaq.info/get/bejne/q6eYab2A3tq5dJ8.html
@liu-river
@liu-river 9 ай бұрын
So this is great, but when the images come in, you can see there is a fraction of second of gray background before the images appear, but the text is instant. Is there a way to avoid that so the image and text appear at the same time? I guess what I mean is like how Unsplash shows a blur image while loading.
@hamedbahram
@hamedbahram 9 ай бұрын
Yes the `Image` component allows you to show a blurred placeholder before the actual image loads. You can read more here → nextjs.org/docs/app/api-reference/components/image#placeholder
@liu-river
@liu-river 8 ай бұрын
@@hamedbahram Hey, thanks for all the hard work you put into this channel, I learned a lot from you. I have another question, instead of passing in a random key, what if we pass in the search param as key so that repeated searches will hit the cache. I am just thinking out loud and haven't tried to implement it. What do you think? BTW the way you solved it in the first place really showed your knowledge of how things work behind the scene, I would never thought of a workaround like that. Very impressive.
@hamedbahram
@hamedbahram 8 ай бұрын
@@liu-river Glad to hear you've learned from my channel. That's an interesting idea 🤔try it out and let me know how it goes.
@liu-river
@liu-river 8 ай бұрын
@@hamedbahram I watched your video again just to consolidate what is happening here. I used the Await helper which is super cool BTW to use in conjunction with Suspense. My theory worked. My app is a filter rather than a search but the logic is the same right, so on searchParams thats already been visited, no waiting, cache hit and page render straightaway. On the other hand searchParams that have not been cached, loading UI kicks in. It's so smooth. I passed key={searchParams.sort as string} to my top div rather than UUID. Thanks again Hamed!
@ekimdev7622
@ekimdev7622 9 ай бұрын
Await method is cool !can we promise.all 2 different promises and await both of them in await function ?
@hamedbahram
@hamedbahram 9 ай бұрын
Yes, definitely
@deepanshuverma3536
@deepanshuverma3536 11 ай бұрын
Its working in Devlopment mode but when prodcution fallback is not showing
@hamedbahram
@hamedbahram 11 ай бұрын
Not sure why you're experiencing that. It works on my end => next-pagination-one.vercel.app/
@deepanshuverma3536
@deepanshuverma3536 11 ай бұрын
is the problem with nginx?
@hamedbahram
@hamedbahram 11 ай бұрын
@@deepanshuverma3536 Not sure!
@AhmedYasser-no1lc
@AhmedYasser-no1lc 2 ай бұрын
When disable js in browser, display skeleton loading page, how when disable js , show skeleton and data or display data only when disable js
@hamedbahram
@hamedbahram 2 ай бұрын
I'm not sure if I understand the question!
@tomassabol59
@tomassabol59 9 ай бұрын
isn't this solution going to introduce hydration errors?
@hamedbahram
@hamedbahram 9 ай бұрын
Why would that be?
@lala-wb7gi
@lala-wb7gi 4 ай бұрын
Suspense fallback is not showing
@hamedbahram
@hamedbahram 4 ай бұрын
Suspense fallback only shows the first time.
@mehdifada-yi5074
@mehdifada-yi5074 11 ай бұрын
merci ke enghad khobi mishe rajebe kar ba headlessUi ham video besazi
@hamedbahram
@hamedbahram 11 ай бұрын
Merc, hatman!
Server vs client components in NextJs 13 - When to use which
34:07
Hamed Bahram
Рет қаралды 33 М.
This UI component library is mind-blowing
8:23
Beyond Fireship
Рет қаралды 635 М.
Каха заблудился в горах
00:57
К-Media
Рет қаралды 9 МЛН
Loading States are Killing Your User Experience
5:15
Josh tried coding
Рет қаралды 45 М.
Goodbye javascript (for now)
14:57
Web Dev Cody
Рет қаралды 68 М.
Next.js 15 Ruins Caching Even More
13:56
Web Dev Simplified
Рет қаралды 41 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 558 М.
The new `useTransition` hook with 3 example usecases
20:38
Hamed Bahram
Рет қаралды 9 М.
NextJS 13 WARNING: Easy Mistake = Infinite Loops
23:46
Jack Herrington
Рет қаралды 48 М.
Server-side Pagination with NextJS 13 Server Actions
19:27
Taylor Lindores-Reeves
Рет қаралды 10 М.
Using Images in Next.js (next/image examples)
9:10
leerob
Рет қаралды 99 М.
Как бесплатно замутить iphone 15 pro max
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
НЕ БЕРУ APPLE VISION PRO!
0:37
ТЕСЛЕР
Рет қаралды 374 М.
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 6 МЛН
Лазер против камеры смартфона
1:01
Newtonlabs
Рет қаралды 737 М.