# Choose Queue, Workflow, or Schedule for TypeScript background jobs

Pick the API from what starts the job and how long it runs. A background job
needs a provider that runs it after the request ends, which an untracked
promise cannot do.

## Match the API to the job

| Job | Use | Reason |
| --- | --- | --- |
| Process an upload after the route replies. | [Queue](https://vitehub.dev/docs/queue) | Delivers a message to a consumer. |
| Create a record, call a service, resume after a failed step. | [Workflow](https://vitehub.dev/docs/workflows) | Tracks runs and steps. |
| Start a daily report at a set time. | [Schedule](https://vitehub.dev/docs/schedule) | A cron trigger starts it. |
| Return a short result in the request. | A server route or inline Agent. | The request owns the work. |

A Schedule can start a Workflow or send a Queue message. Keep the timer apart
from the job to test the job without waiting.

## Choose a provider that owns execution

- **Queue** uses Cloudflare Queues, Vercel Queues, or the local provider of a
  Node server. `pnpm dev` runs jobs in the dev server with the provider's retry
  rules. `vitehub queue jobs list` shows them. A sent message does not mean the
  consumer finished.
- **Workflow** supports Cloudflare, Vercel, and the documented OpenWorkflow
  stores for self-hosting. [Workflow hosts](https://vitehub.dev/docs/workflows/hosts) lists what
  each needs.
- **Schedule** writes the host's cron config where the host supports it. A
  process-based scheduler needs one Node process that stays up, not a
  serverless function. For Netlify or Deno, read
  [Schedule hosts](https://vitehub.dev/docs/schedule/hosts) before you pick the output mode.

## Design for retries and overlap

A delivery or a step can run twice. Use a stable job key and save the result
before you report success. Pass an idempotency key to external APIs that take
one. A retry must not charge a customer or send an email twice.

For a repeating job, decide what happens when the last run is still active.
A cron expression does not coordinate app instances.

## Verify more than the start call

Check one finished job and one failed job, then the retry or restart behavior
your app needs. Check the provider's final state and the external result, not
only the returned ID.

Start with [Queue](https://vitehub.dev/docs/queue/get-started),
[Workflow](https://vitehub.dev/docs/workflows/get-started), or
[Schedule](https://vitehub.dev/docs/schedule/get-started). The
[support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) shows which checks ran
on a live provider.

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/guides.md)
- [Agents](https://vitehub.dev/raw/docs/guides/deploy-agent-cloudflare-vercel.md)
- [Chat bots](https://vitehub.dev/raw/docs/guides/slack-ai-bot.md)
- [Storage](https://vitehub.dev/raw/docs/guides/upstash-redis.md)
- [Databases](https://vitehub.dev/raw/docs/guides/turso.md)
- Server work
  - [Resend](https://vitehub.dev/raw/docs/guides/resend.md)
  - [Cloudflare Browser Run](https://vitehub.dev/raw/docs/guides/cloudflare-browser.md)
  - [Sandbox providers](https://vitehub.dev/raw/docs/guides/sandbox-providers.md)
  - [Background jobs](https://vitehub.dev/raw/docs/guides/background-jobs.md) (this page)
  - [Vercel Queues](https://vitehub.dev/raw/docs/guides/vercel-queues.md)
  - [Cloudflare Queues](https://vitehub.dev/raw/docs/guides/cloudflare-queues.md)
  - [Vercel Cron Jobs](https://vitehub.dev/raw/docs/guides/vercel-cron-jobs.md)
- [Better Auth on Cloudflare](https://vitehub.dev/raw/docs/guides/better-auth-cloudflare.md)
- [Concepts](https://vitehub.dev/raw/docs/guides/rate-limiting-algorithms.md)

Next: [Vercel Queues](https://vitehub.dev/raw/docs/guides/vercel-queues.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
