Rex Documentation

Configuration

Rex is configured via rex.config.toml or rex.config.json in your project root. Both formats are supported — use whichever you prefer. All fields are optional.

If both rex.config.toml and rex.config.json exist, Rex will report an error. Use one or the other.

Redirects

Redirect one URL to another:

[[redirects]]
source = "/old-page"
destination = "/new-page"
permanent = true

[[redirects]]
source = "/blog/:slug"
destination = "/posts/:slug"
permanent = false
FieldTypeDescription
sourcestringURL pattern to match (supports :param segments)
destinationstringURL to redirect to (can reference :param segments)
permanentbooleantrue for 308, false for 307

Redirects are evaluated before route matching.

Rewrites

Serve content from a different path without changing the URL:

[[rewrites]]
source = "/docs"
destination = "/docs/getting-started"

[[rewrites]]
source = "/api/:path*"
destination = "https://api.example.com/:path*"
FieldTypeDescription
sourcestringURL pattern to match
destinationstringInternal or external URL to serve

Rewrites are transparent to the user — the browser URL stays the same.

Headers

Add custom HTTP headers to responses:

[[headers]]
source = "/:path*"

  [[headers.headers]]
  key = "X-Frame-Options"
  value = "DENY"

  [[headers.headers]]
  key = "X-Content-Type-Options"
  value = "nosniff"

[[headers]]
source = "/api/:path*"

  [[headers.headers]]
  key = "Cache-Control"
  value = "no-store"
FieldTypeDescription
sourcestringURL pattern to match
headersarrayList of { key, value } pairs

Build

Configure the build pipeline:

[build]
sourcemap = true

[build.alias]
"@components" = "./src/components"
"@lib" = "./src/lib"
FieldTypeDefaultDescription
build.sourcemapbooleantrueGenerate source maps
build.aliasobject{}Module path aliases for import resolution

Dev

Configure development mode:

[dev]
no_tui = false
FieldTypeDefaultDescription
dev.no_tuibooleanfalseDisable TUI, use plain log output

Full example

[build]
sourcemap = true

[build.alias]
"@components" = "./src/components"

[[redirects]]
source = "/legacy"
destination = "/"
permanent = true

[[rewrites]]
source = "/docs"
destination = "/docs/getting-started"

[[headers]]
source = "/:path*"

  [[headers.headers]]
  key = "X-Powered-By"
  value = "Rex"

  [[headers.headers]]
  key = "Strict-Transport-Security"
  value = "max-age=63072000; includeSubDomains"