io.input.email

An email address, checked before you get it.

io.input.email asks a person for an email address. The browser checks the format before sending. The server checks it again. The handler gets a string it can send mail to.

The simplest one

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

src/actions/stores/inviteOwnerAction.ts
import { app } from '../../app';
export const inviteOwnerAction = app.defineAction({
name: 'Invite owner',
handler: async ({ io }) => {
const owner = await io.input.email('Owner email', {
helpText: 'Gets the invitation',
});
return `Owner: ${owner}`;
},
});
The code. One call in an action, the whole file.
tools.example.com/actions/stores/invite_owner

Invite owner

Owner emailomar@harbor.exampleGets the invitation
Continue
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.input.email('Work email')

Checked twice. Something that is not an address comes back with a message. The server checks every answer, so the browser cannot skip it.

const email = await io.input.email('Email')

No stray spaces. The handler gets a string. The spaces around the address are gone.

.validate(isWorkEmail)

Your own rule. .validate() runs on the server after the format check. Return a message to turn the address down, such as one outside your company.

helpText: 'Gets the invitation'

A hint inside and under. placeholder shows in the empty field. helpText says what the address is for.

io.input.email('Backup email').optional()

Or optional. .optional() lets the field stay empty. The handler then gets string | undefined.

defaultValue: email, disabled: true

Shown, not changed. defaultValue fills the field in. With disabled it shows the address and the handler gets it whatever the browser sends.

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.