M
MastraAI•5d ago
Amos

get workflow status on frontend

what's the best way to query a workflow's status / steps from the frontend if you just have the run id?
5 Replies
_roamin_
_roamin_•5d ago
Hi @Amos ! You can use const result = await workflow.runExecutionResult(runId);
Guria
Guria•4d ago
question was specifically on frontend.
Amos
AmosOP•4d ago
ok guess I can add a backend route to poll this, but was hoping that it was somehow built into the client sdk
_roamin_
_roamin_•4d ago
This is available on the client side 😉
export const mastraClient = new MastraClient({
baseUrl: "http://localhost:4111/",
});

const workflow = mastraClient.getWorkflow("myWF");

const run = await workflow.createRunAsync();

const startResult = await workflow.start({
runId: run.runId,
inputData: {
// ...
},
});

// ...
const result = await workflow.runExecutionResult(run.runId);

console.log(result);
export const mastraClient = new MastraClient({
baseUrl: "http://localhost:4111/",
});

const workflow = mastraClient.getWorkflow("myWF");

const run = await workflow.createRunAsync();

const startResult = await workflow.start({
runId: run.runId,
inputData: {
// ...
},
});

// ...
const result = await workflow.runExecutionResult(run.runId);

console.log(result);
Amos
AmosOP•3d ago
ok but still, would be much nicer to e.g. have a hook that does the polling for you

Did you find this page helpful?