POST requests and cache()
POST requests are automatically deduplicated when using fetch – unless they are inside of POST Route Handler or come after reading headers()/cookies(). For example, if you are using GraphQL and POST requests in the above cases, you can use cache to deduplicate requests. The cache arguments must be flat and only include primitives. Deep objects won't match for deduplication.
utils/getUser.ts import { cache } from 'react'
 
export const getUser = cache(async (id: string) => {
  const res = await fetch('...', { method: 'POST', body: '...' })
  // ...
})
Preload pattern with cache()
As a pattern, we suggest optionally exposing a preload() export in utilities or components that do data fetching.
components/User.tsx import { getUser } from '@utils/getUser'
 
export const preload = (id: string) => {