Skip to main content
Build a server with one action that asks for a name and greets back, then log in and run it.
1

Install

What’s happening here
  • awaitio is the server, the action runtime and the UI.
  • @awaitio/theme-default is how the UI looks.
  • @awaitio/input-text is the text field the action will ask with.
  • zod checks props, answers and action params. AwaitIO works with zod 4, or with zod 3.25 and later through import { z } from 'zod/v4'. In a monorepo, raise every package’s zod to 3.25 or later too: an older pinned zod gets its own copy next to the shared one, and libraries built on it break.
  • In a TypeScript project, also npm install -D @types/react: the component and UI types use React’s, and npm does not add them by itself.
2

Create a session secret

Run this:
and put its output into .env:
.env
What’s happening here
  • The secret is a random string that signs the login cookies.
  • It goes into .env, never into the repository; changing it logs everyone out.
3

Create the app

app.ts
What’s happening here
  • name is shown on the login page, in the header and in the browser tab.
  • actionsDirectory is the folder with your actions: every file in it is one action.
  • theme decides how everything looks.
  • users is who can log in: each person with an email, a name and a hash of their password. AwaitIO has no sign-up and no user database; the list lives in your code.
  • components decides what io offers: input: { text: inputText } gives io.input.text().
4

Write an action

actions/greetAction.ts
What’s happening here
  • Every file in actions/ is one action; app.defineAction() gives it an io typed by the components you registered.
  • name is what the action list shows; every action needs one.
  • The handler gets one object, { io, ctx }: take what you need, async ({ io }) here, async ({ ctx }) for an action that only reads who started it.
  • The handler stops at await io.input.text() until someone answers in the browser, then goes on.
  • What it returns is shown as the result.
5

Start the server

server.ts
What’s happening here
  • listen() loads every file in actionsDirectory and opens the port; the file’s path is the action’s URL: actions/greetAction.ts is at /actions/greet.
  • watch restarts the server whenever you save a file; --env-file=.env passes the session secret.
  • The server listens on 127.0.0.1 only, so nobody else on the network can reach it yet.
6

Create your account

Open http://localhost:3000, click Create new account and fill in your email, name and a password of at least 10 characters. It gives you one line; paste it into users in app.ts:
app.ts
What’s happening here
  • The line holds only a hash of your password; the password itself is not stored anywhere.
  • Saving app.ts restarts the server, and the new user can log in.
  • Everyone else gets in the same way: they click Create new account and send you their line, so their password never reaches you.
7

Log in and run it

Open http://localhost:3000, log in with your email and password, pick Greet, type a name and press Continue.