Open
Description
📋 Explain your issue
Reference Discord conversation: https://discord.com/channels/722131463138705510/1310190736670457856/1310190736670457856
I was able to make background jobs/tasks work in Solid Start via the following method.
- Add this in
app.config.ts
{
// ...
experimental: {
tasks: true,
},
scheduledTasks: {
"* * * * *": ["cron"],
},
}
- Install nitro (this is only used for
defineTask
below and can probably be removed ifvinxi
re-export those types):
pnpm add nitropack
- Create a file in
tasks/cron.ts
(notice this is NOTsrc/tasks
) with the Nitro task definition:
import { defineTask } from "nitropack/runtime";
export default defineTask({
meta: {
name: "cron-name",
description: "Run cron job",
},
run() {
console.log("Running job...");
return { result: "Success" };
},
});
As per Nitro documentation this is only supported in dev, node-server, bun and deno-server presets.
I was asked to open a ticket here to possibly document this. HTH