Skip to content
CafeJS Docs

Static export

One command builds the whole site as HTML, CSS, JS and images, ready for any static host. The admin is used locally only.

Build

Terminal
SITE_URL=https://your-domain.com pnpm build:local

The result is in dist/client/: the whole site as HTML, CSS, JS and images. dist/server/ isn’t needed for this way.

Upload

Upload dist/client/ to any static host: Cloudflare Pages (direct upload), Netlify (drag and drop), or ordinary hosting over FTP.

Warning

The site must sit at the root of its domain (https://your-domain.com/), not in a subfolder, because every link in it starts with /.

Change content

  1. Run pnpm dev and edit in the local admin.
  2. Run the build command again.
  3. Upload dist/client/ again.

The admin in this build

The admin of a static export doesn’t work online (it calls a Tina server on your computer), and robots.txt already blocks /admin/. You can delete dist/client/admin/ before uploading.

Try the build first

Before uploading, you can run the build on your computer:

Terminal
HOST=127.0.0.1 PORT=4064 node dist/server/entry.mjs

then open http://127.0.0.1:4064. An address that doesn’t exist (for example /khong-co/) must show the site’s 404 page.