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. |
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.
@trigger.dev/sdk
into your frontend code:
@trigger.dev/sdk
:
"use server"
on the first line.