T3 Stack Next - Correct method for automating functions every X mins

When using GoogleFu, the usual results are setInterval and run endlessly, but is that the correct method for things happening every 10 minutes for like.. multiplicative datasets? Additionally, is best practice to offload this from the T3 stack and run a separate program? Thanks for all the help!
5 Replies
Samathingamajig
t3-stack applicated should ideally be ran in a serverless/edge environment. if you need CRON-like actions, you can use services Upstash (a sponsor of theo) to configure when to run some of your API endpoints here's video where theo uses it https://youtu.be/zdV_fXjoB-Q
Theo - t3․gg
YouTube
Building With Twitter API In NextJS (FOR FREE!) - TypeScript, Verce...
I love @trash_dev. I also love free content. I hope you enjoy this video of me coding a bot to steal his memes with Upstash (specifically CRONs through QStash), NextJS, Vercel, TypeScript, Discord API, Twitter API, and more. #t3stack #fullstack #webdevelopment This video is sponsored by Upstash! Check them out for all your serverless events, r...
Samathingamajig
don't be afraid of using external services, especially when they have a very generous free tier like Upstash does
cje
cje2y ago
setInterval is never the right answer for this yea you want cron jobs or some cronjobs-like thing if you're deploying to docker you can use actual cron, if to vercel or other serverless provider, upstash is a good place to start like sam said
Debaucus
Debaucus2y ago
Thanks guys! I knew setInterval didn't sit right with the stack, I've seem the Redis upstash video so I'll take a look into it more!
cje
cje2y ago
if you don't want to commit to an external service, you could set up your own cron jobs literally anywhere else (like a vps that you own or whatever) and have an api endpoint in your t3 app that runs the thing when it's hit add an auth header + maybe check origin ip based on an env var on t3 side if you care about security
Want results from more Discord servers?
Add your server