RatMinimal web framework

Setup

Rat is a single binary with no runtime or package manager. The installer puts it on your PATH. The same rat executable scaffolds projects, runs the dev server, and builds static HTML.

1. Install the binary

One command installs Rat for the command line

Downloads the latest release for your platform and adds it to your PATH. Use the downloads page for manual installation.

# macOS / Linux
curl -fsSL https://rat-lang.com/install.sh | sh

# Windows
powershell -c "irm https://rat-lang.com/install.ps1 | iex"

2. Scaffold a project

rat new mysite

rat new writes a project with the standard layout. pages/ holds routed pages and pups/ holds components. styles/, api/, and public/ follow. It also writes a main.rat layout and a settings.rat.

rat new mysite
cd mysite

3. Start the dev server

Hot reload is enabled by default

rat start reads the port and host from settings.rat. It watches every .rat file in the project. On each change it pushes an SSE event, so the page refreshes without a full reload. See hot reload for the details.

rat start

4. Project layout

The basic folder structure of a new Rat app

Files and directories are discovered automatically. There is no central configuration file. pages/foo/page.rat becomes the route /foo (see routing). pups/greeting.rat becomes the greeting tag.

mysite/
  pages/         # routed pages
  pups/          # reusable components
  styles/        # global CSS (.styles.rat)
  api/           # JSON endpoints
  public/        # static assets
  main.rat       # root layout
  settings.rat   # port, host, db, build modes

See also CLI · Settings · Hot reload