# Host your app's backend, database and sign-in (AirHost)

> Use the Hosting, Databases and App Users tabs to see your app's services, logs and deployments, browse its databases, and manage the people who sign in to it.

Source: https://air.build/docs/services/host-a-backend/

AirHost is AirBuild's hosting for your app: a server for its API and website, databases for its data, and sign-in for the people who use it. It's always on, so there's nothing to turn on. Your Agents set it up and deploy to it. You watch and manage it from three tabs in the Project:

| Tab | What it shows |
| --- | --- |
| **Hosting** | The services your Agents deployed, their addresses, logs and deployments. |
| **Databases** | The app's databases, their tables, and a place to run SQL. |
| **App Users** | The people who signed in to your app, and ways to block or delete them. |

## Open the tabs

**iPhone**

Open the Project's chat and tap the tabs button (four squares) in the top-right corner. In the list under the tab cards, tap **Hosting**, **Databases** or **App Users**.

**Mac**

Open the Project's chat and choose **View › Go To › Hosting** (or **Databases**, **App Users**). You can also open the inspector (**View › Show Inspector**, ⌥⌘I), click **New Tab** (**+**) and click the tab.

## Ask your Agents to set it up

While a tab has nothing in it, it asks for the first step. Tap **Ask Agents to Add**, check the words it will send, and tap **Send**. A request goes into the Project's chat for your Agents.

| Tab | What the request asks |
| --- | --- |
| **Hosting** | "Add AirHost to the app" |
| **Databases** | "Add a database to the app". The tab explains: "Keep the app's data in a database on AirBuild's hosting service." |
| **App Users** | "Add sign-in to the app". The tab explains: "Let people sign in to the app with accounts on AirBuild's hosting service. Once the app uses it, the people who sign in appear here." |

After you ask, the tab says "Sent to the project chat" and offers **Open Chat**. You can also just ask in the chat. For how service requests and cards work, see [Add an AirBuild service to your app](https://air.build/docs/services/add-an-airbuild-service/).

## Hosting: your app's services

At the top, four numbers: **Services**, **Live**, **Last Deployed** (with the service's name) and **With Database**. Under them is one row per service, with its address and how long ago it was deployed. The dot beside it shows whether it has been deployed.

Tap the address to open the service in a new Website tab. Tap the row to open the service's page:

| Row | What it shows |
| --- | --- |
| **Status** | **Live**, or **Not Deployed**. |
| **Address** | The service's address. Tap it to open it. |
| **Database** | The database the service uses, or **None**. |
| **Last Deployed** | When it was last deployed, or **Never**. |
| **Size** | How many files and how large the current deployment is. |

Below the details:

- **Live Logs**: what the service prints while it handles requests.
- **Deploy New Version…** (on the Mac): upload a new archive for this service. On iPhone, it's in the service row's menu instead (see below).
- **Deployment History**: every deployment, newest first. The current one is marked **Current**.
- **Export Source…**: download the deployed service as a `.tar.gz` archive and save it.
- **Copy Address**: copy the service's address.
- **Remove Service**: stop the service.

Touch and hold a service's row (on the Mac, right-click it) for **Open in New Tab**, **Live Logs**, **Deploy New Version…** and **Copy Address**.

### Watch live logs

**Live Logs** shows each request the service handles as it happens: when it ran, whether it finished, and what it printed or threw. The badge at the top says **Connecting**, **Live**, **Disconnected** or **Unavailable**. Turn on **Errors Only** to see only failures. Until a request comes in, the page says "Waiting for the service to handle a request…".

The page says: "Logs are live only. Opening them somewhere else replaces this connection." When the connection ends, the badge says **Disconnected**. Tap **Reconnect** to start again.

### Deploy a service yourself (Mac)

Your Agents normally deploy for you. On the Mac you can also deploy an archive by hand.

1. In the **Hosting** tab, click **Deploy** in the inspector's bar.
2. In **Deploy Service**, type a **Name**.
3. Optionally choose a **Database**. Choosing one connects this service to it.
4. Click **Choose Archive…** and pick a `.tar.gz` service archive of up to 10 MB.
5. Click **Deploy**.

To update an existing service, use **Deploy New Version…** instead. The sheet is called **Update Service** and the name can't be changed.

### Remove a service

On the service's page, tap **Remove Service** and confirm. The app says: "_name_ will stop serving requests. Its database, app users and records stay available."

## Databases: your app's data

At the top: **Databases** (how many) and **In Use** (how many a service uses). Each row says which service uses the database, or "Not connected to a service".

Tap a database to open it:

1. Under **Tables**, tap a table. Its first 50 rows load into **Results**.
2. To run your own query, type it under **SQL** and tap **Run**.
3. **Results** shows the rows, how many there are and how long the query took. A query that returns no rows says "The query completed without returning rows."

> [!WARNING]
> **Run** sends your SQL straight to the database. A query that deletes or changes data does so right away, with no undo.

On the Mac, click **New Database** in the inspector's bar to make an empty database: type a **Name** and click **Create**.

To delete a database, touch and hold its row (on the Mac, right-click it) and choose **Delete Database**. The app warns: "This permanently deletes the database and everything stored in it." While a service uses the database, **Delete Database** is dimmed.

A database stays when the service that uses it is removed.

## App Users: the people who sign in

At the top: **All Users**, **Active Today**, **Active This Week** and **New This Week**, then a chart, **New Users (Last 30 Days)**.

Under **Recently Active**, people are listed by when they last signed in, with their email and how they sign in (Apple, Google, GitHub or email). Use **Search by name or email** to find someone. Tap **Load More** at the end to see more.

Tap a person to see **Signs In With**, **Email Verified**, **Joined**, **Last Active** and **User ID**, with **Copy Email** and **Copy User ID**. Two actions are at the bottom:

| Action | What it does |
| --- | --- |
| **Block Access** | "A blocked person can't sign in to any service of this app until access is restored." The person is marked **Blocked** in the list. Tap **Restore Access** to undo. |
| **Delete User** | Asks **Delete App User?**: "This permanently deletes the user's sign-in record for this app." |

## Questions

**Why can't I deploy or create a database on my iPhone?**

**Deploy** and **New Database** are only on the Mac. On iPhone you can read and manage what's running: logs, deployment history, export, remove, and **Deploy New Version…**: touch and hold the service's row in the **Hosting** tab. Or ask your Agents in the chat.

**An action fails with “That Didn't Work”**

AirBuild refused the change or couldn't be reached. The alert says why. Fix what it says, or try again.

**The archive is refused**

The archive must be between 1 byte and 10 MB, and it has to be a `.tar.gz` file.

**Export Source fails with “Unable to Export Source”**

The archive couldn't be downloaded or saved. The alert says why. Check your connection and the place you chose to save it, then try again.

**How do my Agents work with AirHost?**

They use the `workers` command to deploy, query databases and manage app users. See [workers](https://air.build/docs/cli/workers/).
