Skip to main content

Usage

Basic Commands

Create a New Application

regius new myapp

This creates a new web application with all the necessary files and directories.

Optional flags:

  • --db <type>: Pre-fill DATABASE_TYPE in the generated .env (postgres|postgresql|mysql|mariadb|sqlite|sqlite3).
  • -v, --verbose: Stream go get / go mod tidy output live instead of capturing it (the captured output is shown only on failure by default).
regius new myapp --db postgres -v

Show Help

regius help

Displays all available commands and their usage. You can also get help for any specific command or subcommand:

regius make migration --help
regius migrate --help

Check Version

regius version

Shows the current version of Regius.

Database Migrations

Run All Pending Migrations

regius migrate

Runs all pending migrations (defaults to "up").

regius migrate up

Runs all pending migrations explicitly.

Rollback Migrations

regius migrate down [steps|all]

Reverses migrations. Use a number to reverse a specific number of steps, or all to reverse all migrations.

# Reverse last 2 migrations
regius migrate down 2

# Reverse all migrations
regius migrate down all

Reset Migrations

regius migrate reset

Runs all "down" migrations in reverse order, then all "up" migrations.

Check Migration Version

regius migrate version

Shows the current migration version (uses golang-migrate).

Create a Migration

regius make migration create_users_table

Creates two new migration files (up and down) in the migrations folder.

Use the --format=sql flag to create SQL-format migration files:

regius make migration create_users --format=sql

Seeding

Create a Seed File

regius make seed default_users

Creates a new SQL seed file in the seeds/ directory.

Run Seeds

regius db:seed

Runs all pending seed files in seeds/ (in filename order), tracking executed seeds in the regius_seeds table. Seed files are plain .sql files executed in a single transaction, and each is only applied once.

Code Generation

Create a Model

regius make model User

Creates a new model in the data directory with proper pluralization.

Create a GORM Model

regius make gorm-model User

Creates a new GORM model in the data directory with proper pluralization.

Create a Handler

regius make handler Home

Creates a stub handler in the handlers directory.

Create Mail Templates

regius make mail Welcome

Creates two starter mail templates in the mail directory.

Generate Encryption Key

regius make key

Generates a 32-character encryption key for use in the KEY environment variable.

Authentication

Generate Authentication Scaffolding

regius make auth

Creates and runs migrations for authentication tables, and creates models, middleware, handlers, and views.

Session Management

Create Session Store

regius make session

Creates a table in the database for session storage.

Maintenance Mode

Enable Maintenance Mode

regius down

Puts the server in maintenance mode.

Disable Maintenance Mode

regius up

Brings the server back from maintenance mode.

Configuration

All configuration is done through the .env file in your project root. See the Configuration section for details on all available options.

Rendering Templates

Regius provides a unified render.Template interface that works across all three supported template engines: jet, go, and templ. Every handler calls the same Page() method — the only difference is how the Template is created.

Jet Templates

func (h *Handlers) Home(w http.ResponseWriter, r *http.Request) {
err := h.App.Render.Page(w, r, h.App.Render.Jet("home", nil), nil)
if err != nil {
h.App.ErrorLog.Println("error rendering", err)
}
}

Pass jet variables via the second argument:

vars := make(jet.VarMap)
vars.Set("email", "user@example.com")
h.App.Render.Page(w, r, h.App.Render.Jet("reset-password", vars), data)

Go Templates

err := h.App.Render.Page(w, r, h.App.Render.Go("home"), nil)

Templ Components

Templ components implement render.Template natively — pass them directly with no wrapper and no registration:

err := h.App.Render.Page(w, r, views.Home(), &render.TemplateData{Data: data})

Mixing Engines

Each handler independently chooses its engine, so you can mix jet, go, and templ in the same application:

func (h *Handlers) Home(w http.ResponseWriter, r *http.Request) {
h.App.Render.Page(w, r, views.Home(), data) // templ
}

func (h *Handlers) Forgot(w http.ResponseWriter, r *http.Request) {
h.App.Render.Page(w, r, h.App.Render.Jet("forgot", nil), nil) // jet
}