Is there an example of how to use Cloudflare Cron Triggers within Cloudflare Pages?

I want to set up an automated build for my website so it's updated once per 30 minutes. Based on documentation, I set up a trigger within my Cloudflare Pages project but it doesn't seem to show up at the UI. Should Cron Triggers work with Cloudflare Pages? Is there a complete example available somewhere? As a workaround, I could set up cron elsewhere and trigger the build but it feels a bit cleaner to have this logic in the same projects.
17 Replies
Chaika
Chaika14mo ago
Cron Trigers don't work with Pages. You're looking at Workers documentation which is completely seperate from Pages
bebraw
bebrawOP14mo ago
ok, thanks. that makes sense. it's not always clear what's supported and what not. i hope you can consider adding cron support directly to pages one day 👍
Chaika
Chaika14mo ago
They've mentioned wanting to add support before but I would imagine the biggest blocker is dealing with disabling them with old deployments/controls for if they should be active on preview branches/etc But yea, you could make a simple Worker which just calls the deploy hook, or do it with Github Actions
bebraw
bebrawOP14mo ago
yup, i'll do something like that as a workaround - maybe it's worth documenting. thanks a lot for fast turnaround
Borut Svara
Borut Svara5d ago
@Chaika Any update on this? I have a Pages project with built with next-on-pages and would like the possibility to use cron?
Chaika
Chaika5d ago
Cloudflare is switching away from Pages. They've added Static Asset support to Workers, and are promoting opennextjs instead of next-on-pages. It's all still a little beta/early on tho But no, they never directly added cron to Pages
Borut Svara
Borut Svara5d ago
This confuses me even more. In the Dashboard the Pages tab has disappeared and all my Pages projects moved under Workers & Pages. I thought now they are the same. Do you know about any reference explaining what is going on and how to adopt?
Borut Svara
Borut Svara5d ago
Can you also provide some resources for this claim as of Dec 4 2024 the documentation still refers to next-on-pages and so do all examples I was able to find
Cloudflare Docs
Next.js · Cloudflare Pages docs
React framework for building full-stack web applications.
Chaika
Chaika5d ago
They're all under the same section but Workers and Pages are still very distinct things with different features: https://developers.cloudflare.com/workers/static-assets/compatibility-matrix/ CF has said they'll provide some ways to migrate from Pages when they're ready, other then that switching to Workers and Workers Static Assets is a matter of spinning up a new app: https://developers.cloudflare.com/workers/frameworks/framework-guides/nextjs/
We plan to bridge the gaps between Workers and Pages and provide ways to migrate your Pages projects to Workers.
Borut Svara
Borut Svara5d ago
You blew my mind with this 🤯 So if I'm not wrong; under "Workers & Pages" the projects listed there may be either a "Workers" or a "Pages" project (without any tag to distinguish them) and in the two cases the underlying dashboard is different? Btw I would suggest adding a disclaimer to the Pages docs, as all these links have never popped up on Google.
Chaika
Chaika5d ago
You can filter
No description
Chaika
Chaika5d ago
they're also formatted/displayed different and have diff icons
No description
Chaika
Chaika5d ago
their dashboards are also different yea, diff metrics and options, etc There is a header on https://developers.cloudflare.com/pages/framework-guides/nextjs/ssr/get-started/ now but worded more lightly, the adapter is still in beta
Borut Svara
Borut Svara5d ago
@Chaika thank you ❤️ So it's the icons that are changing! If I may be a bit polemical given the drastic change, I would write it in capital letters 😆
Chaika
Chaika5d ago
if it helps to explain: Workers and Pages have always been seperate, and maybe like ~4-5 months ago they got merged under the same dashboard grouping but yea it's a bit messy and has been messy ever since Pages has been a thing, this is part of Cloudflare's convergence efforts they announced a few years ago, will be a lot simpler with just "Workers"
Borut Svara
Borut Svara5d ago
Will try to create a demo projects on worker in the weekend and see how it goes from there. Do you perhaps know if this @opennextjs/cloudflare support cron (and maybe even queue consumers)? Or should I still go about doing dummy workers that call a webhooks?
Chaika
Chaika5d ago
well, Workers support cron so fundementally the support is there, just depends on how opennextjs exports it / how hacky it would be. I'm not sure of that. They have their own discord, could try asking there: https://discord.gg/opennextjs

Did you find this page helpful?