Robin Simonklein
banner
robinsimonklein.dev
Robin Simonklein
@robinsimonklein.dev
#Nuxt enthusiast 💚, side-project addict. Some projects finish, some… well, they’ll get there. ✨
Let’s f* go ! 🤩
March 12, 2025 at 8:15 PM
❤️❤️
November 18, 2024 at 6:48 PM
6/6 - Future-proof

When #NuxtHub adds CRON support for Nitro tasks (likely soon), updating should be as easy as:
- Remove the api route.
- Add a schedule to the task directly.
Your tasks will be ready to go without rewriting the logic!
November 17, 2024 at 4:29 PM
5/6 - Limitations

This approach doesn’t leverage the extended limits of Cloudflare Workers when triggered natively via CRON.
But it’s a solid, temporary workaround to automate while waiting for full CRON support. 🚀
November 17, 2024 at 4:29 PM
4/6 - Trigger your route with CRON

You can now create a CRON task in your external service, pointing to your api route with the appropriate Authorization header :
November 17, 2024 at 4:29 PM
3/6 - Create a POST route

Set up an api route that validates the token and triggers the task:
November 17, 2024 at 4:29 PM
2/6 - Secure your CRON calls

Add a token as an environment variable (e.g. NUXT_CRON_TOKEN) and in your Runtime Config.
Then create a small utility function to ensure only authorized requests can trigger tasks:
November 17, 2024 at 4:29 PM
1/6 - Define a Nitro task

For example, a task that sends weekly emails:
November 17, 2024 at 4:29 PM
If you're using #StimulusJS in your project, give it a try!

chromewebstore.google.com/detail/stimu...
Stimulus DevTools - Chrome Web Store
A developer tool for inspecting and debugging Stimulus applications.
chromewebstore.google.com
November 14, 2024 at 8:43 PM
Lucide icons 🫶
November 8, 2024 at 1:49 PM
Yeah starter packs are a cool feature
November 7, 2024 at 11:45 PM
Oh ok!
November 7, 2024 at 11:44 PM
Fortunately only with Vue 3! Didn’t know that a v3 for Pinia is coming, gonna check that 👀
November 7, 2024 at 5:10 PM
Yeah will talk more about it soon!
November 7, 2024 at 4:57 PM