Prismic content updates not publishing on Netlify with Nextjs 13.4.6 app router

Has anyone has run into any issues when publishing content on Netlify when using the Nextjs app router?.

We recently deployed a new site utilizing Nextjs' app router and cannot see content updates published live unless we clear the Netlify cache and deploy in the Netlify UI. We're waiting to hear back from Netlify support on the issue, but I thought I'd bring it up here in case anyone else has experienced anything similar.

We have a number of other sites on the same version of Nextjs (but not using the app directory) that do not exhibit this behavior. I'm wondering if there is some "gotcha" I missed in the Nextjs or Prismic documentation.

Here's an example page request:

  const client = createClient();

  const page = await client.getSingle("homepage", {
    fetchLinks: ["team.title", "team.subtitle", "team.team_member"],
  });

And our config in prismicio.js:

export const createClient = (config = {}) => {
  const client = prismic.createClient(repositoryName, {
    routes,
    fetchOptions:
       process.env.NODE_ENV === 'production'
         ? { next: { tags: ['prismic'] }, cache: 'force-cache' }
         : { next: { revalidate: 5 } },
        ...config,
        accessToken,
  });

  prismicNext.enableAutoPreviews({
    client,
    previewData: config.previewData,
    req: config.req,
  });

  return client;
};

Hi @jgunderson, using Next.js with the recommended caching settings requires on-demand revalidation to be set up.

We are working to update our documentation with set up instructions, but until then, you can follow the on-demand revalidation instructions in our App Router tutorial: [Tutorial] How to use Prismic with the Next.js App Router - Prismic

You should only need a webhook that sends a request to /api/revalidate; a webhook to Netlify to rebuild the site should not be necessary.

If you find on-demand revalidation does not work on Netlify, I recommend using Vercel or a host that supports on-demand revalidation, or finding a way to clear Netlify's build cache to remove any cached fetch() calls.

1 Like

Thank you @angeloashmore. I followed your instructions, but received the following error on Netlify when triggering the webhook:

Failed to update tags manifest. [Error: ENOENT: no such file or directory, mkdir '/var/task/.next/cache']

It seems that Netlify does not yet support on-demand revalidation: Support for on-Demand Revalidation · Issue #1288 · netlify/next-runtime · GitHub

Do you know of another possible solution to get Netlify to publish content updates without forcing a cache refresh?

Hello, i am also having this same error in my project, is there any solution for this?

We published the site on Vercel, which worked just fine. I'm not aware of any fixes for Netlify as of now.

Thank you, Angelo! works for me in Vercel project.

I have faced a similar problem and fortunately for me I have found a solution. Netlify is currently testing NextJs Runtime v5, you can follow the instructions here. After that all you need to do is setup a hook to https://your-website-domain/api/revalidate and trigger it. I hope this helps.

1 Like