"use client";import { useEventDetails } from "@trigger.dev/react";export function EventDetails({ eventId }: { eventId: string }) { const { isLoading, isError, data, error } = useEventDetails(eventId); if (isLoading) { return <div>Loading...</div>; } if (isError) { return <div>Error: {error.message}</div>; } //get the first run (if one has started yet) const firstRun = event.data?.runs?.at(0); //if the run is there, show the status, otherwise loading return <div>{firstRun ? firstRun.status : "Loading"}</div>;}
React SDK
useEventDetails()
The useEventDetails() React hook will show the live status of an event that was sent using sendEvent().
Copy
Ask AI
"use client";import { useEventDetails } from "@trigger.dev/react";export function EventDetails({ eventId }: { eventId: string }) { const { isLoading, isError, data, error } = useEventDetails(eventId); if (isLoading) { return <div>Loading...</div>; } if (isError) { return <div>Error: {error.message}</div>; } //get the first run (if one has started yet) const firstRun = event.data?.runs?.at(0); //if the run is there, show the status, otherwise loading return <div>{firstRun ? firstRun.status : "Loading"}</div>;}
It will automatically update until all triggered runs with the event have completed or failed.
If you're familiar with React Query, you'll recognize the data that is
returned by this hook. React Query 5 is used internally.
The status of the run. Can be one of the following: PENDING, CANCELED,
SUCCESS, QUEUED, WAITING_ON_CONNECTIONS, PREPROCESSING, STARTED,
FAILURE, TIMED_OUT, ABORTED
"use client";import { useEventDetails } from "@trigger.dev/react";export function EventDetails({ eventId }: { eventId: string }) { const { isLoading, isError, data, error } = useEventDetails(eventId); if (isLoading) { return <div>Loading...</div>; } if (isError) { return <div>Error: {error.message}</div>; } //get the first run (if one has started yet) const firstRun = event.data?.runs?.at(0); //if the run is there, show the status, otherwise loading return <div>{firstRun ? firstRun.status : "Loading"}</div>;}