Next.js for Drupal has everything you need to build a next-generation front-end for your Drupal site: SSG, SSR, and ISR, Multi-site, Authentication, Webforms, Search API, I18n and Preview mode (works with JSON:API and GraphQL).
Currently it is not possible to specify the cache option when using fetch with the Next Drupal client.
Next.js 15 increases the priority for this as it flips the caching semantics to be uncached by default: https://nextjs.org/blog/next-15#caching-semantics Although I'm not sure how much of a problem this is in practice as the docs state:
As a convenience, it is not necessary to set the cache option if revalidate is set to a number.
So that would cover path based revalidation with revalidate. I would hope that the same thing happens if you use the tags option, but would have to test to confirm. Regardless it is still confusing for us to not have a way to directly control this cache option that Next exposes.
Describe the solution you'd like
Update the JsonApiWithNextFetchOptions type to include this cache option.
Update fetchOptions type (or one of the types that it extends) to include this cache option.
In the nextDrupal class, update all calls to fetch to pass the cache option as part of the init object if provided.
Additional context
This is starting to make our withCache option even more confusing. I continue to wonder if that should be deprecated in the future.
Package
next-drupal (NPM package)
Describe the feature request
Currently it is not possible to specify the
cache
option when using fetch with the Next Drupal client.Next.js 15 increases the priority for this as it flips the caching semantics to be uncached by default: https://nextjs.org/blog/next-15#caching-semantics Although I'm not sure how much of a problem this is in practice as the docs state:
So that would cover path based revalidation with
revalidate
. I would hope that the same thing happens if you use thetags
option, but would have to test to confirm. Regardless it is still confusing for us to not have a way to directly control thiscache
option that Next exposes.Describe the solution you'd like
JsonApiWithNextFetchOptions
type to include thiscache
option.fetchOptions
type (or one of the types that it extends) to include thiscache
option.init
object if provided.Additional context
This is starting to make our
withCache
option even more confusing. I continue to wonder if that should be deprecated in the future.