Updating content on live site without redeploying

Hi guys,

I am just wondering if it is possible to update the content of a nextjs website which is using Prismic in realtime, if I update my local updates as soon as the change is made, but on a live site I need to redeploy for the changes to take effect.

Hope that makes sense!

Hey @hachi.studio ,

First, I want to make sure I understand your use case:

  • You have content in Prismic
  • You have a Nextjs site running on localhost and online
  • When you change your content in Prismic, you see the changes on localhost, but you don't see the changes online

Let me know if I misunderstood anything.

Assuming I understood correctly, there could be two issues:

  1. If you have deployed an export of your site.

One of the nice things about Next.js is that you can export your site and upload the export to a hosting provider like Vercel. The downside is that a site like that is 100% static. You need to redeploy manually every time you make any change.

We generally recommend deploying your Next project to a host like Vercel via a GitHub integration, so that when you change your project files, Vercel will automatically rebuild your site.

However, if you've got that working, you still need webhooks.

  1. If you need to set up webhooks.

If, instead of exporting your project, you upload your project files to a service like Vercel, Vercel can build your project for you, so you don't need to worry about building or exporting. You can also connect it to GitHub, so whenever you change your code Vercel rebuilds your project.

Then, you can add a webhook to your project, so that when you change your content in Prismic, it sends a notification to Vercel to rebuild your project. You can learn more about how to do that in the same doc.


I hope I understood your question, and that my answer is helpful. Please let me know if you have any other questions.

Sam

This issue has been closed due to inactivity. Flag to reopen.

I have the same issue, in my live environment, if I change the content in prismic, in my live site I see nothing until I execute npm run build.

I understand that I need a webhook, but I a kind of lost, is any documentation with this process ?

Hello @carlos.martinez

Welcome to the Prismic community, and thanks for reaching out to us.

Learn how to trigger workflows with webhooks in Prismic in the following guide:

Let me know if you have any further questions.

Thanks,
Priyanka

Thanks Priyanka for the quick response, I checked the documentation, but my problem is I donĀ“t know what to do in my App, I`m working with Next.js, what I have to do? I need implement something or just with the configuration of the webhook in prismic is enough ?

You just need to implement webhooks in Prismic.

The way I solved that problem (assuming you are using getStaticProps), is with combination webhooks and revalidation.

So I idea is that you trigger revalidation (for new content) manually, but connecting that specific page route (../api/revalidate..) with webhook and then add the logic.

Check this code, maybe can give you understanding/idea how to approach a problem:

If that can help, we could not use the revalidate on demand because it would be to complicated to configure in case you update the custom types "header" or "footer". That would imply all pages need to be revalidated (all the one with header or footer), and it s not that easy to get the whole list in every locale.

So we ended up using a revalidate : 15 in every page. It means every page is generated every 15s, which is ok for us: Not to long to wait for customers to get the new content, and ok for the nextjs instance to be fetched nth time (n = number of pages) every 15seconds.

I have the same issue, in my live environment, if I change the content in prismic, its not updating in my live site even I execute npm run build.

My case Nextjs hosted in ec2 with pm2. Not static site export using ssr only.

Let me know if you need any additional details

Hi @webdev3, I can see that you've opened a new thread as well. We will respond to you there about this:

For anyone else looking at this, you can use ISR to achieve the effect the OP wants - Better Next.js Sites: On-demand Incremental Static Regeneration