io.confirm

A yes or no before anything irreversible.

io.confirm asks a yes or no question with a Confirm and a Cancel button. It returns true for Confirm and false for Cancel. Either button answers at once, so there is no Continue button. Ask it before you delete, refund or send something.

The simplest one

The whole action file, and roughly what your team sees when it runs.

src/actions/files/deleteArchivedFilesAction.ts
import { app } from '../../app';
import { prisma } from '../../db';
export const deleteArchivedFilesAction = app.defineAction({
name: 'Delete archived files',
handler: async ({ io }) => {
const isSure = await io.confirm('Delete archived files?', {
helpText: 'They cannot be restored.',
});
if (!isSure) {
return 'Nothing was deleted.';
}
await prisma.file.deleteMany({ where: { isArchived: true } });
return 'Archived files deleted.';
},
});
The code. One call in an action, the whole file.
tools.example.com/actions/files/delete_archived_files

Delete archived files

Delete archived files?They cannot be restored.
ConfirmCancel
In the browser. Roughly what your team sees. Your theme decides the details.

What you can set

The settings you will reach for most, each with the line of code that turns it on.

await io.confirm('Delete 12 files?')

One question, two buttons. The question with Confirm and Cancel under it. One click answers.

helpText: 'Their data goes with it.'

Help text. A second line under the question says what happens next.

const isSure = await io.confirm(question)

True or false. Confirm returns true and Cancel returns false. The handler gets a plain boolean.

if (!isSure) return 'Nothing was deleted.'

Stop on Cancel. Return before the irreversible part. The run ends with your message and nothing changes.

await io.confirm('Archive Northwind?')

A step of its own. Ask it on its own, not in io.group. Its buttons send the whole step.

components: { confirm }

Register it once. Install @awaitio/confirm and put it in components. Its key is its name on io.

Write your first tool today.

An async function, a few await calls, and the form is in the browser.

AwaitIO is free for small teams, made possible by companies and people who sponsor it.