next.js
next.js copied to clipboard
Error: cacheLife() can only be called inside a "use cache" function.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/nostalgic-khorana-klzrhl?file=%2Fapp%2Fpage.tsx%3A11%2C1
To Reproduce
- Start the application and preview it
Current vs. Expected behavior
I expect a blank page to be rendered w/o any errors but an error overlay saying "Error: cacheLife() can only be called inside a "use cache" function." is shown.
The docs show examples of the cacheLife
function being used at the top level (https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#caching-entire-routes-with-use-cache), not only inside of functions
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 15.0.2-canary.7 // Latest available version is detected (15.0.2-canary.7).
eslint-config-next: N/A
react: 19.0.0-rc-1631855f-20241023
react-dom: 19.0.0-rc-1631855f-20241023
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response