Next.js Discord

Discord Forum

How to trigger function periodically and dynamically?

Unanswered
Pixiebob posted this in #help-forum
Open in Discord
PixiebobOP
I'm relatively new to Next and wanna know how can I periodically and dynamically trigger a function (e.g., every 2 days, every x days, or on a specific date) in nextjs in the practical way?

4 Replies

are you using vercel? then I would use vercel cron jobs if not inngest could work as well @Pixiebob
basically you set up an API route check the env var got the cron secret if valid then do something on the server ie your function, then theres a vercel.json that points to the route and sets when it should be triggered. Read those docs and ask me any questions.