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)

Reference , ekko:rune/mimir

State: atoms, selectors, hooks, the store, and SSR dehydration. Import:

1
import { atom, selector, useAtom, useAtomValue, useSetAtom, mimir, createStore } from "ekko:rune/mimir";

See the Mimir chapter for the narrative.

atom(config) → Atom

1
atom({ key: string, default: T, persist?: boolean }) frozen Atom<T>
FieldRequiredNotes
keyyesGlobally unique string; identity for storage/hydration/persistence.
defaultyesInitial value (throws if omitted).
persistno (default true)Save to IndexedDB when a session is active.

Returns a frozen definition (__brand: "atom"). Throws if key is missing/empty or default is absent.

selector(config) → Selector

1
selector({ key: string, get: ({ get }) => T }) frozen Selector<T>

Read-only derived state. get(api) reads atoms/selectors via api.get(x); every read becomes a tracked dependency. Recomputes (and notifies) when a dependency changes. Circular dependencies throw Mimir: circular selector dependency at '...'.

Hooks

HookReturnsSubscribes?
useAtom(atom)[value, setValue]yes
useAtomValue(atomOrSelector)valueyes
useSetAtom(atom)setValueno (write-only)

setValue accepts a value or an updater (prev) => next. Writes short-circuit when Object.is(prev, next). useSetAtom accepts only atoms (not selectors).

The store , mimir

The singleton store instance.

MethodSignatureNotes
get(atomOrSelector) → valueComputes selectors.
set(atom, valueOrUpdater) → voidNotifies subscribers + dependent selectors.
reset(atom) → voidBack to default.
subscribe(atomOrSelector, fn) → unsubscribefn(newValue) on change.
snapshot() → objectPlain { key: value } of all set values.
session(mode, opts?) → void"none" | "ephemeral" | "domain"; opts.persistDelay.
clearSession() → voidDrop persisted state, reset persisted atoms, mode → none.
hydrate(atoms) → voidBulk set plain { key: value }.
initStore(serverAtoms) → voidDirective-aware seed (__force/__merge); used during hydration.

SSR dehydration , createStore()

Build the __atoms seed on the server with merge directives:

1
2
3
4
5
const store = createStore();
store.set(atom, value); // plain → fill-if-unset
store.set(atom, value, { force: true }); // force → overwrite
store.set(atom, value, { merge: true }); // merge → deep-merge
store.dehydrate(); // → { key: value | {__force,__value} | {__merge,__value} }

Return store.dehydrate() from ssr().__atoms. See Mimir → SSR & hydration.

Seed directive semantics (initStore)

Entry shapeBehaviour
valueSet the atom only if it has no value (fill).
{ __force: true, __value }Overwrite.
{ __merge: true, __value }Deep-merge into the existing object (or set if none).

Sessions

ModeScope
"none" (default)In-memory only.
"ephemeral"This browser tab/session (cleared on tab close).
"domain"The whole origin (across tabs and restarts).

Under a session, persist: true atoms are written to IndexedDB (db mimir, store kv) with a debounced flush (~100ms). The server communicates the mode via __sessionMode.

Server vs client

Both implementations expose the same surface. The client hooks drive React re-renders (subscribe → setState) and add IndexedDB persistence; the server store is a one-shot used to produce a single render. Write atoms once; they work in both.

Next: ekko:rune/seo.