Want to know how to make static pages in Next.js update automatically without rebuilding your site? This video covers everything about ISR (Incremental Static Regeneration) in Next.js with a real database example, live testing, and animation for better understanding!
✅ Learn: What is ISR and how it works How to write the export const revalidate = 60 code Difference between static and dynamic pages What happens when data is deleted or updated Live example + animation to explain ISR perfectly Key points to remember while using ISR ------------------------------------------------------------------------ 🚀 Boost Your Skills with these Pre-Requisite Videos:
⌛TIMELINE⏳ 0:00 What is ISR in Next.js? 0:56 ISR Code – Just One Line! 1:25 Must-Watch Recap Before Deep Dive 1:40 Static vs Dynamic Page with Database 3:50 Why Static Pages Can Be a Problem (Disadvantages) 5:05 How to Use ISR in Next.js (Real Example) 6:05 Testing Refresh Behavior: Static vs Dynamic 8:20 Common Doubt Solved with One More Example 9:55 Let's Understand ISR with Animation 14:01 Key Points About ISR You Must Remember 15:40 How to Keep Most of the Video Relevant 16:10 Thank You – Keep Supporting Guys!
Hello what's up guys today in this video
we will see ISR in next application.
Yes guys, today's video is very
important. And what is this ISR
? Today in this one video I am going to
give you live demo with complete practical.
Ok? So here you can see
what the full form of ISR, the official Next JS application says? Look,
first of all see its full form.
This is your incremental static
regeneration. Incremental static
regeneration. Ok? Now what happens with this?
Look at its advantages. What is it
providing you? Updates the static
content without rebuilding the entire site.
Yes guys, this is the only point
which if you remember, your life is going to
become very easy. Because in
next we have SSG SSR then this
ISR and many more such short
forms which are widely used. And
you will get confused. Hey what is this?
What is that? But if you remember this one point,
your life is going to become very easy. So
guys, before reading the remaining three points,
I want to tell you
that this is what ISR means. This is
your ISR. Yes guys, I don't know how
many of you might have liked this incremental static
regeneration. But
this is its real form. Export cost
revalidate equal to, whatever time you want to
give, you can give it in seconds.
I will tell you what this means.
This is our video from yesterday. And if
you haven't seen yesterday's video yet, Static
vs Dynamic Pages in Next Jas,
please check it out.
I showed you in very depth, live, that too
with my Sequel database,
what is happening. Ok? You can see it here. Let
me just show you one more time,
quick. Ok?
So that everyone remains on the same page.
Look carefully. Which one am I in right now? I am in a
static page. You can see it here.
Right? So you have my last element which is
coming from this database. Basically
who is that record for me? It's Alex. Ok?
If I go there on dynamic,
what is my last record here also? It's Alex. Right? Both have
Alex in them. But what are you? If I now
go to the database, basically to the workbench my
sequel, and I tell it that this ID
number of doctor 35 should be deleted.
I will delete this.
Ok? I'll go over here. Now I
select all star from doctors. Basically
I have to see a doctor. So now you
can see very clearly over here that the number
35 is no longer there. Because we have
deleted them. So what should my last record
be now? It must be Fatima.
Right? So here I go now.
Look carefully. This is the dynamic part. And
I just deleted it in front of you. And we have
already
connected Next JS with our My Sequel. So
whatever change I make there will be
reflected here. Right? So now if
I flash this.
Look carefully. Still here we have an Alex.
Guys look carefully. Duck dhak dhak dhak and
boom guys. C Look at this, you can see it.
Now our one second. Now our last record is
what? Fatima. Ok? But if
I go on static. Right now I was
on dynamic pages. Obviously,
in dynamic, the data will be rendered dynamically.
But if I walk on static, look, I have
seen it. Still we are getting Alex but
I had deleted Alex. So
this is the problem with static content,
basically with static pages, that once
you build your application then
it becomes final. After that, any
user who requests this page will
always see the same data because the last
time this application was built,
Alex's records were available in it.
Right? After build, we have already built it.
So after building
I deleted it, what does this have to do with it? This
means that this data was present when it was last built. So this is the problem with static. The
problem is clear, isn't
it? Brother, I deleted it, then
why am I still seeing Alex here
? It is not in my records but
Dynamic has shown it to me, so this is where
your ISR comes in handy. Where
now it has the ability to make even static pages dynamic.
Ok? You
have a static page. It has many advantages.
We do not allow the load to occur. Every
time I request a static page, the
request is not coming from the server.
This cash is stuck somewhere. The
data is coming in rapidly. Butt the same dynamic happens every time a
request is made to my server. It
brings the data from there. So this is very fast
brother. This static is very useful in blocks etc.,
which is a very good thing.
But there is one shortcoming here. And this is the
drawback that once it is built, it does
not get updated. So why don't we
have some power through which I
can update it. Yes guys, the
work of ISR is to keep your static page
up to date. Let me tell you how. I
found out the funda. Why do I have to
use ISR so that next time if
I refresh then that data gets updated here also.
Two it is static,
even if data gets updated without building it then your
ISR works there. And I told you
not to do anything for ISR. Just copy this.
Ok? Come on code. Come to your static page.
I'm going here.
Go to the end top and write it like this.
What do you want to write? Export
cost revalidate equal to 60. So instead of 60,
I will make it 30. I asked
what will he do after 30 seconds? Once you
build it. Ok? Let me show you.
Look, let me go here. I
am building this. Alright guys, so you
can see that this is our build.
And I had already told you which is a static page and which is a
dynamic page.
Here we have this
particular thing. See, F means
dynamic. O means static. Ok?
I am now running the build that I made.
npm run and then start. Previously I used to
write npm run and then deb. But now
I am writing start. It means whatever
I built, I am running it.
Ok? So now let's see what happens.
I am walking here. Look carefully.
Alex is here, friend. This is my static.
Now I have just built it. So
obviously I'm not going to get Alex
because that's running while I'm building.
Then he checked everything.
Checked the database, checked here, whether everything is
up to date or not. He looked. Hey
Alex, it has been deleted. So now
I can't find Alex here. Now
look carefully. I built it again and I
also added the ISR to it. Now what will happen is that
once you build. After that
I gave a time period of 30 seconds here.
So after the build is done if 30
seconds passes. Ok? After that, if
any user makes a request, he will
check again whether any changes have happened in this page
or not. Basically here there is the date of the database
so the database will check whether any
changes have happened or not. So if there are any changes then
that guy will show it to us here. Let
me tell you. Look at this carefully.
Look carefully at how this will happen. For
example,
what did I do to this ID 35? Delete. Now I am
inserting them back. Ok?
Some such code is already written. I
did the run. So now let me run this back.
Look at this for
a second. He went there over here. You
can look carefully. And that's it, I
got Alex back. Because I
added them back. Now look carefully.
I don't need to say this if I am on
static pay. Ok? Now my last
record is Fatima over here. But
recently I saw that I had
added Alex. Now if I refresh,
still I am getting what Fatima. Still
what did I get? Fatima. For the very
first time. And remember
brother, from the time I built it till now it's been
more than 30 seconds. But still
I got a still data. But now
look carefully. I am still in static
page only. But the moment I refresh.
And boom guys see this is it. This is
your ISR, even in static page your
data gets updated after build. This is
so powerful, you understand that the
data has been updated, that too in a static page,
that too after building it. So this is
incremental static regeneration regenerated.
Ok? I know guys, now you
guys may have a doubt here. And that is
why the data was not updated the first time
? Right? Why did the data get updated only when I clicked the end second time
?
Keep this in mind. I will explain the whole thing to you
through PPT. Ok? Now I don't
need to talk about the guys dynamic.
This is the nature of dynamic. Look,
in dynamic, whatever I change,
I will get it. I go back here.
I am deleting this again. Ok?
Deleted it back.
Guys please look at this very carefully. Ok?
Back to Alex Gap Alex isn't it last
record Fatima I'm here to go.
It's your dynamic page here we go.
So you can see that there
is no tension in Fatima Dynamic because every
time the request is going to the database. 2.
This is definitely time consuming. But now
if I go to static. Look,
requesting on a static page means
again this is my third request. There
is a third request. You should keep this in mind.
If I hit enter, look, still I am
getting what Alex,
right, this means this is wrong,
I had deleted Alex and
before coming to the static page, I went to the dynamic page, it had been
deleted there, but
why did it not happen here, but now look again at the
moment, I will refresh it, alright now, now
you can see, now this happened, you are seeing
what happened here, how did you like it, I
mean now I will tell you what happened, you have to
look carefully here. We have a
PPT. Alright guys. So you can see
that I have come to PPT. And I
hope you got the complete idea
what this ISR is and how it
works. If you still have any doubt then please
watch this video once again.
But after understanding this PPT
all your doubts will be cleared. Ok?
Imagine that you have created an application.
end ok? You built it at 12:00.
Ok? And when you built, you had
10 entries in your database. How many? There
were 10 entries. Now
look at the timeline carefully here. Correct?
When you built the page at 12:00
you had 10 entries. Ok? 12:30
What did you do? Deleted two entries
from my database. And exactly at 1:00 pm, i.e.
1 hour after build, for the first
time someone requested that static page.
Ok? And if we see, we have
given a timing of 60 seconds on ISR at this time.
I had given 30 seconds earlier but now
we have kept 60 seconds here. And
obviously you are building at 12:00
and at 1:00 someone is making a request, then
60 seconds have obviously passed. Now
what the user will see is very
important. And we have already seen it live.
Now you will know better in theory.
Look, immediately
whatever the catch version is, you will see it.
Those months, the first user, the
very first user, will
see the same old stale data. Ok?
But what will happen with this? The moment you
request a page for the first time,
ISR is used. Now he
regenerates back. Regenerate he did.
He saw that there were some changes. So Willy doesn't like
you so he got the data gate in a jiffy.
I mean it regenerated in the background.
So there is an advantage for the second user
because as soon as the first
request came, we used ISR
and it is already more than 60 seconds.
It had already been 1 hour. Isn't it? It
regenerated data from the background.
So when the second user comes then look at him, get the
fresh I mean fresh version of eight
entries. This is very important. And
now listen to this carefully. Once the second visitor gets a
new entry. Ok? So
as soon as the new entry is updated on the page,
then it will be held for 60 seconds.
So within those 60 seconds, whether you
say that your fourth or third request has been done
, your fourth request has been done, your fifth
request has been done, your sixth request, so
many users will come and go, they will still see the
same thing. The same data has to be shown. Now,
in this you can also assume that
as soon as the second visitor visited, he
saw the new data, fresh data. Let's assume
after 20 seconds what did I do next?
Another data was deleted.
What did I do to another data? I deleted it. So
what will happen here now? Look carefully.
This is important. Yes. Time given was 60 seconds.
After 20 seconds what did we do?
Delete the key. How much is still left? 40 seconds
remaining for ISR to regenerate again.
So now look carefully. Now within these 40
seconds, whatever requests will
come, this is what I said, third, fourth,
fifth, sixth, they will see the same old data, that
means the one in which two data were deleted
and from there 40 seconds are passed, okay
then let's say which seventh user came, seventh
user came, alright, you will not see it,
I will continue it here, when the
seventh user comes, then that seventh user,
believe me, he will also see the same old data
in which there were eight entries. And
as soon as the person with the seventh request sees these eight
entries,
you know what will he do next? Hey, 60
seconds is over. Let's
regenerate again. Then, the 8th
user will see fresh data
again within 1 minute of the data that we had deleted.
And he
saw fresh data again. Then from there again there was a
60 second hold. Within 60 seconds,
delete whatever has been updated;
whatever you do, they will see the same three data that was deleted.
So guise this is how it
works. Look at this,
how easy ISR was to say. But I hope you
figured it out. Here you can see no
automatic background updates. ISR only
regenerates when someone requests the page
after the revalidate period. I have
explained it to you. Now you are able to understand it in a better way,
right? Still data is
served first. User Never Wait For The
Regeneration. Zero Down Time Page Is Always
Available Even During The Regeneration Feels.
Obviously it is static, so once it is built
it will definitely be visible. what
can we do? But this was your ISR and if you have
seen it, it is so small. You think
he is still a child. This is just one line
here. So there is only one line.
But how does that one line work? You
see, this is very important. So I
hope you liked the video very much.
Guys, this takes a lot of hard work.
Like I explained this to you, I
mean, imagine how long it took me to
figure out what was
going on, brother? Is it automatically refreshing in the background after every 60 seconds or
after every 30 seconds
? No, nothing like that was happening.
It doesn't get triggered unless someone makes a request.
And someone
even requested it, poor guy is
seeing only the old data. Why is the end visible
? I have told you the reason. Isn't it? So this
is a very important concept.
Finally you are giving a world to the static page also. Are you
giving me one life or two brother you are a static
page. But still we will see updates in you.
You will get the opportunity to get updates
and that ISR is providing it.
So this is so awesome, isn't it? Like, the
request is coming from the server, we are getting cached data
and in that also we are getting up to date
data. What else do you want brother?
So ya guys this is it. That's it for this video today. I
hope you found out.
If you are still confused,
I guarantee. Just watch this video
carefully one more time. All your
doubts will be cleared. And whatever I
showed you, you must practice it yourself once.
Because Source Code
& Notes is absolutely free. And PPT,
I know many of you said that they are
not giving PPT. But I will update that also.
Because there is
not that much in the PPT. The main thing is the video, the
content is important. Ok?
So that's why guys please I am working very hard.
And I hope you
guys are enjoying it too. I also
want you to motivate me in return.
I am not asking for money, I am not
asking for anything. I just want you to
like the video. At least it is absolutely free, you will
not lose even ₹1. Tell me by commenting. Even I am
replying to every comment
brother. You can post useless comments elsewhere
brother. like this like that hey it's cool. No one pays any attention to you
there. Does anybody reply? I do
not give. But I am also replying to you. I am
clearing your doubts.
Brother, there must be some meaning in it when I am doing so much.
So I want you to please
like, comment and share
on Instagram. Hey I was not able to understand this.
But now I finally understand it.
If you have any doubt, you
can also ask on Instagram by making a video. Is
n't it? So I will reply there as well. And if you have
n't subscribed to the channel yet,
please do so guys. Our next
target is 8 lakh centimeter and
a bell icon appears on right side. Hit that
so that you don't miss such awesome videos daily.
So guys, see you
in the next video. Till then guys thank you
so much. Take care.
[music]