Pages

Page URL

Every page has a relative URL. The app's home page is always /.

See Protocol - Pages and URLs.

Page Stack

The frontend keeps a stack of pages. The top-most page is visible to the user.

The first time the app starts, it starts with only ApplinConfig.showPageOnFirstStartup url on the stack.

Widget actions can push or pop pages on the stack. The stack cannot become empty.

The frontend saves the page stack. If the OS stops the app, the frontend restores the page stack when the user opens the app again. The frontend also saves and restores user-entered data (text fields, checkboxes, etc.). This means the user can continue using the app where they left-off.

If the user forcefully terminates the app, the frontend erases the page stack. The next time the app starts, it shows the default page:

  • If the server previously set a "session" cookie, then it starts with page /.
  • Otherwise, it starts with the value of ApplinConfig.showPageOnFirstStartup.

Page Variables

Some widgets allow the user to enter data or select options. We call them input widgets. For example, text_field and checkbox are input widgets.

Every input widget has a var_name attribute, for variable name.

When the page refreshes or performs an RPC action, the frontend sends the page's variables to the backend in a JSON object HTTP POST body. See Protocol.

The frontend saves variables values in a single dictionary for all pages. Widgets on different pages can use the same var_name and they will show the same data.

Static Pages

Static pages are defined in frontend code.

Refresh

The user can refresh the page by:

The page refreshes smoothly.

# Ruby
nav_page(title: "Inert") {
  scroll {
    form(widgets: [
      text("This page updates when you load or refresh it (pull to refresh)."),
      text(Time.new.strftime("%Y-%m-%d %H:%M:%S")),
    ])
  }
}
#![allow(unused)]
fn main() {
nav_page(
    "Inert",
    scroll(form((
        text("This page updates when you load or refresh it (pull to refresh)."),
        text(format!("{:?}", SystemTime::now())),
    ))),
)
}

Polling

Pages with the poll_seconds option will automatically refresh. The page refreshes smoothly, even while the user is typing on the keyboard.

# Ruby
nav_page(title: "Polled", poll_seconds: 2) {
  scroll {
    form(widgets: [
      text("This page updates automatically every 2 seconds."),
      text(Time.new.strftime("%Y-%m-%d %H:%M:%S")),
    ])
  }
}
#![allow(unused)]
fn main() {
// Rust
nav_page(
    "Polled",
    scroll(form((
        text("This page updates automatically every 2 seconds."),
        text(format!("{:?}", SystemTime::now())),
    ))),
)
.with_poll(2),
}