next.js/test/production/app-dir/browser-chunks/app/cache-client.tsx
cache-client.tsx15 lines462 B
'use client'

import { unstable_cache } from 'next/cache'

// Importing next/cache in a Client Component should not pull server internals
// into browser chunks. The bundler sets NEXT_RUNTIME='' for client builds,
// which allows cache.js to DCE the server require() branch.
const getCachedData = unstable_cache(async () => {
  return { data: 'hello' }
})

export function CacheClient() {
  return <button onClick={() => getCachedData()}>Fetch cached</button>
}
Quest for Codev2.0.0
/
SIGN IN