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.
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/greet.ts
What’s happening here
  • Every file in actions/ is one action; app.action() gives it an io typed by the components you registered.
  • 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/greet.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.