Documentation

Docs

Introduction

What is rune

Philosophy

Why rune

Architecture

Getting Started

Installation

Quick start

Project structure

The dev loop

Tutorial: build an app

1. Create the app

2. Pages & routes

3. Layouts

4. State with Mimir

5. SSR & data

6. API routes

7. Styling

8. Build & deploy

Core Concepts

The application object

Rendering pipeline

Hydration

The build manifest

Configuration (ekko.json)

Permissions

Conventions

Routing

File-based routing

Dynamic routes

The router (useRouter)

Navigation & Link

Guards & redirects

Programmatic routes

Server-Side Rendering

Overview

The ssr() function

Strategies (eager/lazy)

SSR → hydration

Caching & invalidation

SEO

Mimir, state management

Overview

Atoms

Reading & writing

Selectors (derived state)

Subscriptions & the store

SSR & hydration

Persistence & sessions

Patterns & recipes

Pitfalls

Pages & Layouts

Pages

Layouts

Error & not-found

API Routes

Defining routes

Request & response

Middleware

helmet

cors

rateLimit

bodyLimit

validateContentType

csrf

requestId

timeout

errorHandler

httpsRedirect

secureCookies

ipFilter

safePath

Validation & options

Styling & Theming

SCSS

Theming (light/dark)

Asgard integration

No flash (no-FOUC)

Building & Deploying

The build

Static assets

Production deploy

API Reference

ekko:rune

ekko:rune/router

ekko:rune/mimir

ekko:rune/seo

ekko:ssr / css

ekko.json schema

CLI commands

Guides

Rune app from scratch

Recipes

Dark mode

Forms

Data fetching

Authentication

Pagination

FAQ (use cases)

Documentation

Docs

Introduction

What is rune

Philosophy

Why rune

Architecture

Getting Started

Installation

Quick start

Project structure

The dev loop

Tutorial: build an app

1. Create the app

2. Pages & routes

3. Layouts

4. State with Mimir

5. SSR & data

6. API routes

7. Styling

8. Build & deploy

Core Concepts

The application object

Rendering pipeline

Hydration

The build manifest

Configuration (ekko.json)

Permissions

Conventions

Routing

File-based routing

Dynamic routes

The router (useRouter)

Navigation & Link

Guards & redirects

Programmatic routes

Server-Side Rendering

Overview

The ssr() function

Strategies (eager/lazy)

SSR → hydration

Caching & invalidation

SEO

Mimir, state management

Overview

Atoms

Reading & writing

Selectors (derived state)

Subscriptions & the store

SSR & hydration

Persistence & sessions

Patterns & recipes

Pitfalls

Pages & Layouts

Pages

Layouts

Error & not-found

API Routes

Defining routes

Request & response

Middleware

helmet

cors

rateLimit

bodyLimit

validateContentType

csrf

requestId

timeout

errorHandler

httpsRedirect

secureCookies

ipFilter

safePath

Validation & options

Styling & Theming

SCSS

Theming (light/dark)

Asgard integration

No flash (no-FOUC)

Building & Deploying

The build

Static assets

Production deploy

API Reference

ekko:rune

ekko:rune/router

ekko:rune/mimir

ekko:rune/seo

ekko:ssr / css

ekko.json schema

CLI commands

Guides

Rune app from scratch

Recipes

Dark mode

Forms

Data fetching

Authentication

Pagination

FAQ (use cases)

rateLimit()

Throttle requests per client IP in a sliding window, and reject the ones over the limit with 429.

rateLimit request flow

Use case

Login, signup, password-reset, and write endpoints are brute-force and abuse magnets. A rate limit caps how many requests a single client can make in a window, which blunts credential stuffing, scraping, and accidental request storms, without you tracking anything by hand.

How it works

It keeps a per-IP counter in memory (a null-prototype map, so a crafted IP string cannot poison it). Each request increments the count for the current window; when the count exceeds max, it replies 429 Too Many Requests and stops. On every allowed request it sets X-RateLimit-Limit and X-RateLimit-Remaining so well-behaved clients can back off before they are blocked.

Configuration

OptionDefaultNotes
max100Max requests per window.
window60000Window length in ms.
message"Too many requests"The 429 body's error field.

Example

1
2
3
import { rateLimit } from "ekko:web";
 
app.use(rateLimit({ max: 300, window: 60_000 })); // 300 req/min per IP, app-wide

For a tighter limit on a sensitive endpoint, prefer a per-route limit so a generous global limit and a strict login limit can coexist:

1
app.api("POST", "/api/login", { rateLimit: { max: 5, window: 60_000 } }, async (req) => login(await req.json()));

Notes

The counter is per-IP and per-process (in-memory). For multi-process or multi-host deployments each instance counts independently, set the limit accordingly, or front it with a shared limiter at the proxy for a global ceiling. Behind a proxy, make sure req.ip is the real client IP, not the proxy's.

Next: bodyLimit.