Day-04
β Incremental Site Regeneration in next.js
π if static site generation sort pried of time regeneration so its call ISR.
π it only existed when use static site generation present.
π regeneration trigger call revalidate variable second me time provide
π revalidate add two different place one is Page Level and second is fetch level ;
1. export const revalidate = 5
2. const await fetch("_",{next:{revalidate:5}})β Force Static to Dynamic Page
π Dynamic page build on req time not the build time
π static page dynamic generation using export dynamic variable
export const dynamic = "force-dynamic"π also support different value like: force-dynamic,error,auto,force-static and by default set value auto
π if page inside use searchParams,Cookies,Headers,connection,defaultMode,fetch etc so automatic make dynamic page
π forcefully dynamic page make it static so params,searchParams,Cookies etc show empty value
π if default value error forcefully dynamic page make it static then build time error cause for this is dynamic page.
β Streaming in next.js
π streaming use for long page or components stream in chunk so page load faster
π stream enable wrap page or components in Suspense
<Suspense fallback={<div>Loading...</div>}>
<div>long Content or dynamic content</div>
</Suspense>π Suspense give fallback content show when data not yet. if data coming isCompleted then fallback content remove and actual content show
β Server Components and Client Components
π server comp. only run on server
π client comp. run on both side server and client
π client comp. when need interactivity on page
π make client comp. so add top on page "use client" keyword
π react hook etc use on client comp. support
π Any child comp. inside all component automatic become child component
β Hydration Error on Next.js
π if render html and server html are not match so throw hydration error
π if any link add on page so hydration error possible
π Error show only on Development mode not in production
π its user experience not good