Cron jobs
SolidStart supports scheduled background tasks through Nitro's Tasks API. Tasks run on the server and are not exposed to the client.
Scheduled tasks are only supported in the dev, node-server, bun, and deno-server Nitro presets.
Configuration
Enable the tasks feature in app.config.ts:
import { defineConfig } from "@solidjs/start/config";
export default defineConfig({ server: { experimental: { tasks: true, }, scheduledTasks: { "* * * * *": ["cron"], // run every minute }, },});The scheduledTasks object maps cron expressions to arrays of task names to run on that schedule.
Creating a task
Create your task file inside the tasks/ directory at the project root (not inside src/):
import { defineTask } from "nitropack/runtime";
export default defineTask({ meta: { name: "cron", description: "Scheduled background job", }, run() { console.log("Running scheduled job..."); // put your server-side logic here return { result: "Success" }; },});The task name in meta.name must match the name used in scheduledTasks in app.config.ts.
nitropack is a transitive dependency of SolidStart. If TypeScript cannot resolve the
import, add nitropack as an explicit dev dependency:
npm install -D nitropack# orpnpm add -D nitropackRunning tasks on demand
You can trigger a task manually via the Nitro task endpoint during development using a GET request:
curl http://localhost:3000/_nitro/tasks/cronThis is useful for testing your task logic without waiting for the scheduled time.
The /_nitro/tasks/* endpoint executes server-side code on demand. In production deployments
(node-server, bun, deno-server), this endpoint is publicly reachable by default.
Protect it behind authentication, IP allowlisting, or route-level middleware before
deploying to a public environment.