Skip to main content

Documentation Index

Fetch the complete documentation index at: https://confect.dev/llms.txt

Use this file to discover all available pages before exploring further.

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. Both runAfter and runAt accept a ref to a mutation or action and an optional args object matching the ref’s args schema.

Run after a delay

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

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

  yield* scheduler.runAfter(
    Duration.minutes(5),
    refs.internal.messages.send,
    { 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, refs.internal.messages.send, {
    text: "Happy new year",
  });
});
For the full scheduling APIs, see the Effect Duration documentation, the Effect DateTime documentation, and the Convex scheduling documentation.