Skip to content
cloudhostDocs
Get started

Get started in a few minutes

Create an account, install the CLI, sign in from the terminal and deploy your first function and app. Then connect a database, a cache and storage to your code.

1. Create an account#

Sign up on the sign-up page with your email and an Iranian mobile number. There are no passwords: a 6-digit code goes to each, and later you sign in with a code sent to either.

Sign-up is by invite for now. An invite from a team also works, even while sign-up is closed.

Every account starts with a personal team on the Hobby plan. Everything you make belongs to a team; see Teams and roles for roles and teammates.

2. Install the CLI#

curl -fsSL https://ibel.ai/install/install.sh | sh
cloudhost help

The installer downloads a single executable from our own server, checks its signature and checksum, and needs nothing else; the npm package needs Node.js 22 or newer. cloudhost update keeps it current (the CLI). It calls the same public API the dashboard calls, so everything here also works from the dashboard and the API.

3. Sign in from the terminal#

cloudhost login
# Open https://dash.ibel.ai/device?code=WDJB-MJHT
# and check the code shown there is WDJB-MJHT.
# logged in as you@example.com (owner)
cloudhost whoami

cloudhost login prints a link and a code. Open the link, check the code matches and approve; the dashboard asks for a second factor to approve. The CLI receives an API key with your role in the team, valid for 90 days, and keeps it in ~/.config/cloudhost/config.json. You never type a password or code into the terminal.

4. Deploy a function#

A function is a standard web handler: a module whose default export has fetch(request, env, ctx). TypeScript works; the CLI bundles your entry file and its imports into one module.

export default {
  async fetch(request: Request): Promise<Response> {
    const url = new URL(request.url);
    return Response.json({
      hello: url.searchParams.get("name") ?? "world",
      path: url.pathname,
    });
  },
};

Every function gets its own address: https://<name>.fn.trustpage.ir.

Each deploy makes a new version. cloudhost functions versions hello lists them and cloudhost functions rollback hello goes back to the previous one without rebuilding anything. More in Functions.

5. Deploy an app#

An app is static files, with an optional function for paths that have no file. Put your site in a folder and deploy it:

mkdir public && echo '<h1>salam</h1>' > public/index.html
cloudhost apps deploy my-site ./public
# deployed app my-site v1 (1 files, 1 uploaded, 640 ms)
# https://my-site.app.trustpage.ir

Only new or changed files are uploaded. For Next.js, Astro, single-page apps and _headers and _redirects rules, see Apps.

6. Connect a database#

cloudhost db create shop
# created database shop (branch main)
#   host      shop.database.trustpage.ir:5432
#   database  shop
#   user      app
#   password  …   (shown once)

The password is shown once; cloudhost db password shop makes a new one. The database sleeps when idle and wakes on the next connection.

To use it from a function, bind it. The function reads it as env.DB, with no password in your code:

type Env = { DB: { query(sql: string, params?: unknown[]): Promise<{ rows: Record<string, unknown>[] }> } };

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    await env.DB.query("create table if not exists visits (at timestamptz default now())");
    await env.DB.query("insert into visits default values");
    const { rows } = await env.DB.query("select count(*) as n from visits");
    return Response.json(rows[0]);
  },
};

7. Use the cache and storage#

cloudhost cache create sessions
cloudhost cache run sessions SET greeting salam
cloudhost cache run sessions GET greeting
# salam

The cache also works with any cache client, and the bucket with any storage client; see Cache and Storage.

Next steps#