Tasks need to be triggered to run.
Function | Where does this work? | What it does |
---|---|---|
yourTask.trigger() | Anywhere | Triggers a task and gets a handle you can use to monitor and manage the run. It does not wait for the result. |
yourTask.batchTrigger() | Anywhere | Triggers a task multiple times and gets a handle you can use to monitor and manage the runs. It does not wait for the results. |
yourTask.triggerAndWait() | Inside a task | Triggers a task and then waits until it’s complete. You get the result data to continue with. |
yourTask.batchTriggerAndWait() | Inside a task | Triggers a task multiple times in parallel and then waits until they’re all complete. You get the resulting data to continue with. |
schedules.task()
to trigger it on a recurring schedule. Read the scheduled tasks docs.
trigger()
or batchTrigger()
.
TRIGGER_SECRET_KEY
environment variable. You can find the value on the API keys page in the Trigger.dev dashboard. More info on API keys.
trigger()
or batchTrigger()
. You can also trigger and wait for the result of triggered tasks using triggerAndWait()
and batchTriggerAndWait()
. This is a powerful way to build complex tasks.
Don't use this in parallel, e.g. with `Promise.all()`
batchTriggerAndWait()
if you can, or a for loop if you can’t.To control concurrency using batch triggers, you can set queue.concurrencyLimit
on the child task.Don't use this in parallel, e.g. with `Promise.all()`
maxConcurrency
. Alternatively, use sequentially with a for loop.To control concurrency, you can set queue.concurrencyLimit
on the child task.@trigger.dev/sdk
into your frontend code:
@trigger.dev/sdk
:
"use server"
on the first line.