--- title: "Wait until" description: "Wait until a date, then continue execution." --- import PausedExecutionFree from "/snippets/paused-execution-free.mdx" This example sends a reminder email to a user at the specified datetime. ```ts /trigger/reminder-email.ts export const sendReminderEmail = task({ id: "send-reminder-email", run: async (payload: { to: string; name: string; date: string }) => { //wait until the date await wait.until({ date: new Date(payload.date) }); //todo send email const { data, error } = await resend.emails.send({ from: "hello@trigger.dev", to: payload.to, subject: "Don't forget…", html: `
Hello ${payload.name},
...
`, }); }, }); ``` This allows you to write linear code without having to worry about the complexity of scheduling or managing cron jobs.