“Realm DATA”

Realm.js talks to backend and expects data in this format:

pub struct PageSpec {
    pub id: String,
    pub config: serde_json::Value,
    pub title: String,
    pub url: Option<String>,
    pub replace: Option<String>,
    pub redirect: Option<String>,
    pub preload: Vec<String>,
    pub cache: Option<CacheSpec>,

id: This is an Elm module name. This Elm module is the main Elm app for the page. This app runs in document mode.

config: This is JSON that is passed to Elm app, and contains all the data a page backend may want to pass to page frontend.

title: This is the title of the page. Realm updates the title of page.

url: Sometimes, say in POST and then GET pattern, the URL requested (POST done on), is not the same as the one returned (GET one), as realm does internal redirect avoiding one HTTP roundtrip. If this field is set, realm updates the document.location (without triggering reload; TODO: what happens in non modern browsers?). The URL is also added to the navigation stack, so clicking back and forward works as expected.

replace: Sometimes we do not want to add the URL in the history, but want to update the URL in browser location bar, so reload keeps you on right place, and back avoids the intermediary place. Eg from a->b->c (replace), browser navigation stack only contains a->c, killing b. Useful if b was some sort of “flow breaker”, eg login page.

redirect: This is to do a browser based redirection. Since request to backend has been made as an Ajax request, we can not redirect on backend, so backend sets this field to URL we want to go to, and Realm takes user to that page. This can not yet be combined with replace. (TODO: maybe both replace and redirect should be set to bools, or better yet, we have a enum representing “behaviour”, encapsulating all valid things we may want to do).

preload: Every URL in this list, Realm.js preloads and caches them (it will revalidate cache when the page is actually rendered, as is true for all pages served from cache). These URLs could be “realm URLs”, meaning their JSON should be fetched, if the URL are relative and don’t start with /static. Absolute URLs, or URLs starting with // are pre-cached assuming they are not realm-URLs.

pub struct CacheSpec {
    etag: Option<String>,
    purge_entire_cache: bool,
    id: Option<String>,

etag: Optional opaque string, used for caching.

purge_entire_cache: If set to true, Realm purges entire cache (other than realm:elm-<hash>).

id: Cache ID. Default value is “default”. Can be set to None to disable caching for current page.

Table Of Content

What is Realm?

A Bit On Motivation

Routing is Hard

What does Realm do?

Backend Data And Type Safety


Quick Start Realm Tutorial

In Depth Tutorial (not ready)

Hello Rust
Hello Elm
Hello Static Files
Hello Server Side Rendering
Pre-Commit Hooks

Routing, Request And Response

Frontend, Data, Navigation, And APIs

How To Guides

File Upload

Backend: S3 File Upload
Authenticated File Serving
Frontend: Uploading Files From Elm

How to use storybook?

How to implement “loading..”?









Environment Variables

Internals - Only for Realm Developers, not Users

“Realm DATA”
iFrame Controller
Shutdown Routine
Testing Internals

Change Log

Get Realm Starter Working

Transparent Offline Feature

How to make http requests in Realm?


Replay Testing

Tutorial: ToDo App

Realm Testing

Enhance Realm Starter

Double Load Issue

Deploy To Heroku Button

End failure

Realm-Starter Github Template

Proposal: Tracker And Visit

Proposal: Activity Store

Proposal: Bundling

Proposal: Retry On Network Error

Storybook: Editable JSON

Storybook: Notes

Storybook: Reference



Change Log

How to Publish


Code Snippets

Skip rustfmt For Some Section

Close Modal Dialog When Clicked Outside

Ignoring Lints In Python

Ignoring Lints (clippy and rustc warnings) In Rust

Handle DateTime in Rust & Elm

Handle CiText value read in Rust

Transport Enum Type to and fro Rust/Elm through JSON