Environment Variables

Realm does not have a settings file or such, and relies on environment variables for things that are configurable (and generally believes in making as few things configurable as possible).

Here you will find all the environment variables, their purpose and their default value.


This is the port on which realm listens on.

We do not prefix this variable because this is what Heroku sends us.

TODO: Also support REALM_PORT (with higher precedence).


This is the database URL, this is passed to diesel’s underlying database driver as is.

TODO: link to sqlite and PostgreSQL related pages to explain how to construct this url.

This is a mandatory parameter and no default value is assumed. Realm starter project sets it to sqlite with hello.db as file path.

Note: This variable doesn’t start with REALM_ because a lot of frameworks support this (eg Django, Diesel).


This is used to sign cookies if you are using UserData framework.

TODO: Document UserData and link to it.



A string containing the URL which points to our web application. If this variable is unset, realm assumes that you are working on localhost and all the links will be generated using this URL.


This is the “index file”, which acts as a template for the HTML that is returned by realm.

Sample index.html. This is also used in case the REALM_INDEX is not set, or if it points to a file that is not present or can not be read.

<!DOCTYPE html>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <script id="data" type="application/json">

        <style>p {margin: 0}</style>
        <div id="main"></div>
        <script src='/static/elm.js'></script>

It has a few special markers: __realm_title__, and __realm_body__, these are replaced with html title, JSON and SSR content respectively.

During development (in non release mode), this file is read on every request, in release mode, it is read when the server starts and is not updated till server starts again.


This is the folder that is watched. If this folder changes, iframe.js file is rebuilt. This is used for auto reloading /storybook/ page.


If the watched directory changes, this is the command that is run to build the latest iframe.js file.


This is the path of generated iframe file. It is generated via the REALM_WATCHER_DOIT_CMD command.


This environment variables value is ignored and we only check if it is set or not. If it is set, some extra debug statements are printed on stdout that tell what file was tried for what realm::Page implementation.


This activates “pure mode” in realm, which is used to improve performance by storing publicly accessible version of every URL in CDN, showing it first to user, and then replacing it with personalised version.

The value of this environment variable is expected to be the key for “user data” in DATA.config, which is merged into pure version to show proper header etc.

To disable this feature, unset the variable or set it to empty string.


Realm uses hyper, an async http framework, but converts it to sync for playing nice with diesel etc. We use a thread pool to achieve this.

Thread pool size can be controlled using this environment variable.


realm::base::pg::connection() and related helpers use r2d2 for database connection pooling. The database pool size can be controlled using this environment variable.


Realm stories can be embedded in IFrames to be viewed in the realm project. As a security measure, the /storybook/ route returns the stories only if the referer in the request matches the referers specified by this environment variable.

The URLs have to be separated by ,.

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