forked from vercel-labs/next-partial-prerendering
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
RecommendedProducts, | ||
RecommendedProductsSkeleton, | ||
} from '#/components/recommended-products'; | ||
import { Reviews, ReviewsSkeleton } from '#/components/reviews'; | ||
import { SingleProduct } from '#/components/single-product'; | ||
import { Ping } from '#/components/ping'; | ||
import { delayRecommendedProducts, delayReviews } from '#/lib/constants'; | ||
import { Suspense } from 'react'; | ||
|
||
export const revalidate = 60; | ||
export const generateStaticParams = () => { | ||
return []; | ||
}; | ||
|
||
export default async function Page({ | ||
params, | ||
}: { | ||
params: { | ||
id: string; | ||
}; | ||
}) { | ||
console.log('==> Rendering page'); | ||
return ( | ||
<div className="space-y-8 lg:space-y-14"> | ||
<div className="text-2xl font-medium text-white"> | ||
Streaming Demo {params.id} {new Date().toISOString()} | ||
</div> | ||
<SingleProduct | ||
data={fetch(`https://app-router-api.vercel.app/api/products?id=1`)} | ||
/> | ||
|
||
<Ping /> | ||
|
||
<Suspense fallback={<RecommendedProductsSkeleton />}> | ||
<RecommendedProducts | ||
path="/streaming/node/product" | ||
data={fetch( | ||
// We intentionally delay the response to simulate a slow data | ||
// request that would benefit from streaming | ||
`https://app-router-api.vercel.app/api/products?delay=${delayRecommendedProducts}&filter=1`, | ||
{ | ||
// We intentionally disable Next.js Cache to better demo | ||
// streaming | ||
cache: 'no-store', | ||
}, | ||
)} | ||
/> | ||
</Suspense> | ||
|
||
<Ping /> | ||
|
||
<Suspense fallback={<ReviewsSkeleton />}> | ||
<Reviews | ||
data={fetch( | ||
// We intentionally delay the response to simulate a slow data | ||
// request that would benefit from streaming | ||
`https://app-router-api.vercel.app/api/reviews?delay=${delayReviews}`, | ||
{ | ||
// We intentionally disable Next.js Cache to better demo | ||
// streaming | ||
cache: 'no-store', | ||
}, | ||
)} | ||
/> | ||
</Suspense> | ||
</div> | ||
); | ||
} |