Skip to content
cloudhostDocs
Guide

Apps

Static sites and full-stack apps: static files with an optional function for paths that have no file. Next.js and Astro are detected and built.

A static site#

cloudhost apps deploy my-site ./dist
# deployed app my-site v1 (48 files, 48 uploaded, 1.9 s)
# https://my-site.app.trustpage.ir

Files are stored by content: the CLI sends each file's hash and uploads only the ones we do not have yet. How many files, how large each and how large in all depends on the plan: see Limits. A /404.html, if there is one, is served for unknown paths.

Upload from the browser#

In the dashboard, New project takes a folder, a .zip or a .tar.gz by drag and drop. A folder with an index.html at the top goes live at once as a static site (_headers and _redirects apply). A project whose package.json lists a framework or has a build script is built on our servers, and you watch the build log live there. node_modules, .git and build output are not sent.

Every upload is checked before it is stored or built: paths that leave the project (../), links and special files, and the sizes and file counts. Uploads are up to 25 MB and 2,000 files on Hobby, 100 MB and 20,000 files on Pro.

Terminal
cloudhost apps upload my-site ./dist        # a static site
cloudhost apps upload my-shop site.zip      # a framework project: built, log followed

Limits#

What one deployment of an app may hold, by plan. The app's function code is measured as it is stored: all its modules together, compressed with gzip.

LimitHobbyProEnterprise
Static files in a deployment20,000100,000By contract
The size of one file25 MB25 MBBy contract
All static files of a deployment, added up500 MB5 GBBy contract
The function's code, compressed3 MB10 MBBy contract
The function's code before compression64 MB64 MBBy contract

cloudhost deploy checks a deployment against your plan's limits before it uploads anything, and a build on our servers does the same before its output is uploaded; the API checks again. A deployment over a limit is refused with the code limit_exceeded (HTTP 413), and the message names the limit, your deployment's size, your plan's number and Pro's, for example: "Static files in a deployment: this deployment has 25,000 files; the Hobby plan allows 20,000 files, Pro allows 100,000 files." Enterprise limits are set by contract. The same limits are on pricing, and GET /v1/limits returns them for your plan and every plan.

_headers and _redirects rules#

/*
  X-Frame-Options: DENY
  X-Content-Type-Options: nosniff
/assets/*
  Cache-Control: public, max-age=31536000, immutable

Put these two files at the root of the files folder. _headers takes up to 100 rules and _redirects up to 2,000, with status 200 (a rewrite), 301, 302, 303, 307 or 308.

Single-page apps#

An app with only static files, an /index.html and no /404.html is taken as a single-page app: every unknown path gets /index.html, so the client-side router can do its work. An app that also has a function gets the same with --spa (or spa = true).

Deploy
cloudhost apps deploy my-spa ./dist --function api.ts --spa

An app with a function#

// runs only when no static file matches the path (here, /api/*)
export default {
  async fetch(request: Request): Promise<Response> {
    const url = new URL(request.url);
    if (url.pathname.startsWith("/api/")) return Response.json({ api: url.pathname, ok: true });
    return new Response("not found", { status: 404 });
  },
};

An app's function runs only for paths with no file; static files are served directly and cost no function time. Everything functions have (environment variables per environment, crons, bindings, logs) is there for an app's function too, with cloudhost apps …. The files themselves are also in env.ASSETS for the function.

Next.js and Astro#

Deploy
cd my-shop
cloudhost init
cloudhost deploy
# Next.js: building on our builder
# build 1a2b3c4d queued (412 KB of source)
# ── install (npm ci)
# ── prepare Next.js for the edge runtime
# ── build (Next.js)
# ── deploy
# deployed app my-shop v1 (…)
# https://my-shop.app.trustpage.ir

cloudhost deploy detects the framework from package.json and builds the project on our builder, as git push does: the builder adds and configures the runtime adapter in its own copy of the source, so you install nothing and no file is added to your project. The output is deployed as static files and a function: prerendered pages, pages rendered per request, route handlers and endpoints. For these projects [build] command is not run; the framework's build takes its place. framework = "none" in cloudhost.toml turns detection off.

FrameworkWorksNot yet
Next.js 16Static and server pages, route handlers, 404ISR and image optimisation; set cacheComponents: false in next.config.ts
Astro 7Static and on-demand pages, endpoints, 404Sessions (Astro.session) and image transforms; images are served as they are

Previews, builds and git#

git remote add cloudhost https://git.ibel.ai/my-shop.git
git push cloudhost main          # production
git push cloudhost new-menu      # https://new-menu--my-shop.app.trustpage.ir

Apps have the same previews, remote builds and git push as functions; see Functions. A preview is a good place to review a content change before it reaches main.