Skip to main content
The Scheduler service schedules Confect functions to run in the future. It wraps Convex’s scheduler with Effect-native types: delays use Duration and timestamps use DateTime.

Run after a delay

import { Duration, Effect } from "effect";
import { Scheduler } from "./confect/_generated/services";

Effect.gen(function* () {
  const scheduler = yield* Scheduler;

  yield* scheduler.runAfter(Duration.minutes(5), functionReference, {
    text: "Hello",
  });
});

Run at a specific time

Effect.gen(function* () {
  const scheduler = yield* Scheduler;

  const dateTime = yield* DateTime.make("2030-01-01T00:00:00Z");

  yield* scheduler.runAt(dateTime, functionReference, {
    text: "Happy new year",
  });
});

Function references

The Scheduler accepts Convex SchedulableFunctionReference values β€” the same function references used by vanilla Convex’s scheduler.runAfter and scheduler.runAt. See the Convex scheduling documentation for more details.