hermet hermet SSR. Islands. Rust.

Your first site

You create a site with only one page, build it, view it in a browser, and change one sentence. It is the smallest possible site, with no login and no database. You read the contents of the files after the site runs.

1. Create the site

# Run this where you want the my-site folder to be created
hermet new my-site
cd my-site
hermet check
  • hermet check checks the configuration and the files. hermet build compiles the site's Rust code.
  • If there are no problems, the output includes No problems. If it shows a diagnostic, fix the file it names and run it again.
  • The site's name (here, my-site) becomes the name of the Worker (one program that runs on Cloudflare Workers). The name must start with a lowercase letter and use only lowercase letters, digits and -. It must be 63 characters or fewer and must not end with -.
  • hermet new sets up the new site so that it gets Hermet from GitHub, at the same version as the hermet you use, and builds with it. It writes these settings in Cargo.toml. If you work in a clone of the repository, pass its location to --hermet-path. The site then uses the Hermet in that clone.

2. Build the site

hermet build

hermet build compiles the site's Rust code and creates the set of files that is sent to Cloudflare. It does not use a Cloudflare token. The first time, installing worker-build takes 1–2 minutes (only once), and compiling, including the libraries the site depends on, takes about 30 seconds.

  • The main outputs are the Worker itself in build/, the configuration for running locally in .hermet/wrangler/default.json, and the build record in .hermet/build-record.json. If the site has images, JavaScript to serve, or files at a fixed URL (files you put in public/, such as favicon.ico), files are also written to .hermet/public/.
  • If the build stops with an error: a Rust compile error is shown with the file name and the line number. If a Hermet check stops the build, the error is shown in the same form as in hermet check. Fix the problem, then run hermet build again.

3. View it in a browser

If you have a Cloudflare account and an API token, and you want to deploy the site to try it, go to "Deploy to Cloudflare and view it" (you do not need Node.js). If you want to try it only on your machine, without an account, go to "Start the Worker locally and view it" (you do not need Node.js for this either).

Either way, the step succeeds when the page you open shows the heading "my-site" and the sentence "Running on Hermet."

Deploy to Cloudflare and view it

Prepare a Cloudflare account and an API token that is allowed to deploy Workers. Set the token in the environment variable CLOUDFLARE_API_TOKEN in the terminal where you run the commands. To keep the value out of shared files and the command history, see Handling the API token. When you run these steps, a Worker is deployed on Cloudflare.

# Set CLOUDFLARE_API_TOKEN to the value of your token, then run these
hermet check --deploy
hermet deploy
  • When the deploy succeeds, open the workers.dev URL that is printed. Anyone who knows the public URL can open the page in this example.
  • The Worker name is my-site. Deploying explains how to use separate Workers for production and for development.

Start the Worker locally and view it

To open this minimal site on your machine, run hermet dev. It uses neither Node.js nor Wrangler. Nothing is deployed to Cloudflare.

hermet dev
  • It runs the same build as hermet build, then prints Ready: http://127.0.0.1:8787. Open that URL. To stop it, press Ctrl-C.
  • The first time only, it downloads workerd, the runtime Cloudflare runs Workers on. It is about 45 MB. Before it uses the download, it checks that the file is not damaged. From the second time, it starts at once.
  • D1, KV and R2 use storage that exists only on your machine (.hermet/dev/ in the site folder). At start, it applies the SQL files in db/migrations/<binding name>/ that are not applied yet. With --fresh, it starts from empty storage.
  • The page cache and Purge also work, with local stand-ins. If you open the same page twice, the second response comes from the cache. But this is not Cloudflare's cache itself. To check the Purge rate limit and the time a purge takes to reach every data center, deploy to a development Worker.
  • Sites that use R2 and sites that use static generation also run on hermet dev. If a site uses a setting that hermet dev does not support (such as extra settings for public files), it says so and stops. In that case, install Node.js and use npx wrangler@4.162.0 dev --config .hermet/wrangler/default.json.

4. Change one sentence

Open src/pages/home.rs and change Running on Hermet. to Hello from my site!.

src/pages/home.rs
pub struct HomeView {
    message: &'static str,
}
hermet::template!(HomeView, "pages/home.html");   // binds this type to the HTML

pub async fn load() -> Result<HomeView> {
    Ok(HomeView { message: "Running on Hermet." })
}
  • If you deployed the site: run hermet deploy again, then open the same URL again.
  • If you run the site locally: when you save a file, hermet dev prints the files that changed and builds again. When the build finishes and the new version takes over, reload the page in your browser. (During the switch, which takes about a second, you may get a 503.) If the build fails, the error is printed and the previous version keeps running. To turn off watching for changes, add --no-watch.

If the page shows "Hello from my site!", it works. This file has two parts: the type passed to the template (HomeView) and the function that makes its value (load). The value goes into home.html, next to this file. load takes no arguments. So it does not read a database: it makes the value only from what you deployed with the code.

src/pages/home.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>my-site</title>
{hermet:head}
</head>
<body>
<h1>my-site</h1>
<p>{message}</p>
</body>
</html>

{message} is a placeholder. The Rust type HomeView puts its message here. {hermet:head} is where Hermet puts the tags that load CSS and JavaScript (JS), among other things. The generated files have it once, inside <head>.

Try it

Add one more <p>{message}</p> to the HTML. Next, misspell it on purpose, as in {mesage}, and run hermet build. You see that a field that does not exist stops the build at compile time. hermet check --full also finds the same mistake. When you are done, change it back to {message} and build again.

5. Look at the generated files

Start with these three files.

  • To change the data shown on the page → src/pages/home.rs
  • To change the page's HTML → src/pages/home.html
  • To add or change a URL → src/manifest.rs
File Contents How often you edit it
Cargo.toml The settings of the Rust project. It depends on hermet and worker, and uses hermet-build and hermet-config only when building Sometimes
build.rs Takes cloudflare.rs in and calls hermet_build::run_site(&site::site()). On every build, it reads the configuration, checks the templates and CSS, and collects them Rarely
cloudflare.rs The Cloudflare configuration: the Worker name, the compatibility date, storage, cron, and so on. No wrangler.toml is created When you add a mode or storage
src/lib.rs Defines the Gate and the Renderer. Only the Gate can be reached from outside (How it works) Rarely
src/manifest.rs The list of pages. For now, one page: / Each time you add a page
src/pages/mod.rs Includes the Rust files of the pages Each time you add a page
src/pages/home.rs The Rust of the first page. It prepares the data shown on the page Most often
src/pages/home.html The HTML of the first page Most often
.gitignore What Git does not track (target/, build/, .hermet/, and so on) Never

src/manifest.rs says: "At /, build the page with the home.rs function load, and cache it until the next deploy." It passes the load function to Page::at as it is.

src/manifest.rs
pub fn app() -> App {
    App::new(hermet::generated!())
        .page(Page::at("/", home::load).until_deploy())
}

You write the Cloudflare configuration as ordinary Rust, in cloudflare.rs at the top of the site folder. This example sets the Worker name and the compatibility date. The compatibility date says which point in time of Cloudflare Workers' behavior the site uses. A set of settings that you switch between is called a mode. The minimal site has one, default. hermet build and hermet deploy use it when you leave out --mode.

cloudflare.rs
use hermet_config::*;

pub fn site() -> Site {
    Site::new(default)
}

fn default(_: &Ctx) -> Result<Config, ConfigError> {
    Ok(Config::new().compatibility_date("2026-11-13").worker(Worker::new("my-site")))
}