Skip to main content

Documentation Index

Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt

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

Tasks

Tasks are user-defined functions in tasks/ that can run locally via veryfront task <name> or in the cloud as Jobs and Cron Jobs.

Quick start

Create a task file:
// tasks/sync-data.ts
export default {
  name: "Sync external data",
  description: "Pull latest records from the external API",
  schedulable: true,

  async run(ctx) {
    const response = await fetch("https://api.example.com/records");
    const data = await response.json();
    return { synced: data.length };
  },
};
Run it locally:
veryfront task sync-data

Task definition

A task file exports a TaskDefinition object as its default export:
interface TaskDefinition {
  name?: string;
  description?: string;
  inputSchema?: Record<string, unknown>;
  outputSchema?: Record<string, unknown>;
  schedulable?: boolean;
  run: (ctx: TaskContext) => Promise<unknown> | unknown;
}
FieldRequiredDescription
nameNoHuman-readable name
descriptionNoWhat the task does
inputSchemaNoJSON-schema-like input contract for APIs and UIs
outputSchemaNoJSON-schema-like output contract
schedulableNoWhether it can be used as a cron job target
runYesThe function to execute

Task context

The run function receives a TaskContext:
interface TaskContext {
  env: Record<string, string>;
  config: Record<string, unknown>;
  projectId?: string;
}
  • env — filtered environment variables (use envAllowlist to restrict)
  • config — job configuration (passed when run as a cloud job)
  • projectId — project identifier (available in cloud context)

Discovery

Tasks are discovered automatically from the tasks/ directory:
tasks/
  sync-data.ts           → task ID: "sync-data"
  reports/weekly.ts      → task ID: "reports-weekly"
File extensions .ts, .tsx, .js, .jsx are supported. Test files and node_modules are ignored.

Running tasks

CLI

# Run a task by ID
veryfront task sync-data

# List discovered tasks
veryfront task --list

As a cloud job

Tasks with schedulable: true can be targeted by Jobs and Cron Jobs:
import { VeryfrontJobsClient } from "veryfront/jobs";

const jobs = new VeryfrontJobsClient({
  authToken: process.env.VERYFRONT_API_TOKEN,
  projectReference: "my-project",
});

await jobs.create({
  name: "Daily sync",
  target: "task:sync-data",
  config: { batchSize: 100 },
});
See Jobs & Cron Jobs for scheduling and event monitoring.

Next