Create serverless functions that run on specific intervals.
keep-alive
that creates, then subsequently deletes, a temporary page
object in the database. This is a little workaround to prevent databases going to sleep after a period of inactivity. You should probably remove this if you don’t need it.
Additionally, while you can add cron jobs to any app, we use the api
app to keep our background jobs, webhooks and other such tasks isolated from our UI.
You can add new functions by creating the relevant route.ts
files in the apps/api/app/cron
folder. While you can put them anywhere, we use the aptly named cron
folder to hold our endpoints designed to run as cron jobs. For example:
vercel.json
file in the API app. To serve as an example, we’ve wired up the keep-alive
job mentioned above to run every 10 minutes.