Next.js · Middle · Question 63 of 75
With Cache Components, how do you keep new Date() out of the static shell?
async function CurrentTime() {
await io()
return <p>{new Date().toISOString()}</p>
}- ✓Correct answer: Call
await io()fromnext/cachebefore reading it, inside a<Suspense>boundary - 2Wrap it in
'use cache' - 3Use
Date.now()instead
Explanation
'use cache' captures the value once for everyone. io() suspends during prerendering; unlike connection(), it doesn't block prefetching.