Get started with your own database.

Pages and Database Driven Website Hosting Pages can serve any content type (HTML, JSON, CSS, RSS, text etc) through an URL endpoint directly from your database.

They are perfect to use for:

  • a database driven website (we can host your domain - see section at the end)
  • reports
  • dashboards
  • feeds
  • pre-made database views (for example in JSON or XML)

You code the view templates using server-side HandlebarsJS tags together with your content type. Pages can also act as components in other Pages by including one in another (see the #include tag below).

Demo site:

For a good example of a site created entirely with Pages, visit You can view (and steal) the source code to see how things are done.


Creating Pages with HandlebarsJS

The output from a Handlebars template is injected in the HTML (or other content type) on the server before it is sent to the browser. Pages rendered with server templates are fast and demands very few resources from your browser.

General HandlebarsJS tags you can use with Pages can be found here. specific Handlebars-tags and helpers are:

contextRun database queries and bind data to Page context
includeReuse another Page as a fragment
inheritInherit master page layout
blockPlace output in master page layout
ifCondLogic statement
tojsonOutput encoded JSON
rawjsonOutput unencoded JSON
momentDate functions from moment.js library
authPassword protect pages
_String functions from library
markdownRender text as Markdown

The various halpers are explained below.


The context defines the data you can display on a Page. It could be a plain JSON object (great for testing), but the main use case is to run one or several database queries and make the result available through Handlebars tags.

In the HTML example below, we fetch data from one collection (contacts), using a query that will give us contacts of category 'customer'.

The query and hints part of the definition are the same we use for the REST API queries. Note that 'query' is required, 'hints' is optional. See the "Querying with the API" docs for details.

      "mycust": {
          "collection": "contacts",
          "query": {"category": "customer"},
          "hints": {"$orderby": {"name": 1}}}

            <h1>My customer contacts</h1>
                {{#each mycust}}
                    {{name}} {{phone}}

JSON data view example

Creating a data view of the same data in JSON is simple. You just change the content type of the Page to application/json (in the settings menu of the Page) and write the content in the appropriate format (JSON).

      "mycust": {
          "collection": "contacts",
          "query": {"category": "customer", "_createdby":"{{user}}"},
          "hints": {"$orderby": {"name": 1}}}
      {{#each mycust}}
      {{#unless @last}}

Tip: use {{{tojson mycust}}} to inspect the jsondata or {{{rawjson mycust}}} to output the unescaped jsondata into the page html (note the three brackets) .


To include one Page in another we just use the include tag with the name of the Page we wish to include. This makes it easy to reuse HTML partials across many pages.

    <h1>My page title</h1>
    {{include "page-name"}}
    <p>Some text ... 

inherit page layouts with #block

The #inherit tag lets you reuse a complete page layout by replacing only #block's inside the "master template". First, create a "master page", name it what you like, e.g. masterpage.

    <!-- The masterpage -->

Next, create a "content page" that will reuse the "master page" layout, name it what you like, e.g. contentpage.

    <!-- The content page -->
    {{#inherit "masterpage"}}
        {{#block "title"}}
        The page title

        {{#block "content"}}
        The page content here.
        Something else here.


The output from this page will now be merged into the "master template" to produce the following output.

    <!-- The output html -->
            <h2>The page title</h2>
            <p>The page content here.
        Something else here.


This tag will render the content as HTML. The text content must be written in markdown syntax.

{{#each article}}
  {{markdown content}}


Use this tag to compare values. The compare operators supported are these standard Javascript operators:

"!=="Not equal
"<"Less than
"<="Less than or equal
">"Greater than
">="Greater then or equal
"~"Regular expression match

Example statement using the Equals operator:

{{#ifCond value "===" value2}}
    Values are equal!
    Values are different!

_ (lodash)

Call a utility function from the Lodash library.

For example rounding a number:

{{_ 'round' customer.salary 2}}


This tag will output a context variable directly to JSON.

{{{tojson projects}}}


This tag will output a context variable unescaped directly to JSON.

{{{rawjson projects}}}

moment - helper for dates

Note that this helper does not use the hash symbol (#) and does not need an end tag. The variable (here: datereceived) must be a valid date.

{{#each application}}
  <p>{{subject}} - {{moment datereceived format="DD/MM/YYYY"}}</p>

More examples of MomentJS Handlebars formatting can be found here. You can also check out the MomentJS site.


This tag instructs the server to require an authenticated user.

The example below shows hot to protect a page with a simple username and password.

{"password": "secret", "user": "jane"}

A more elaborate example using a database Collection to authenticate users against.

    "user": {
        "collection": "myusers",
        "query": {"username": "{{}}", "password": "{{credentials.pass}}"}

    "password": "{{user.0.password}}", "user": "{{user.0.username}}"


Output a substring from another.

{{trimString str 0 50 '..'}}

Predefined variables

Predefined variables you can use in Pages are:

  • {{root}}
    • When you refer other pages, this will always be the correct root. For example if you reference a CSS file named styles.css, you should use it like this <link href="{{root}}/mycss" rel="stylesheet">
  • {{user}}
    • the email of the logged in user (on private pages)
  • {{params}}
    • the query string from the browser as a map, ie.{{params.title}} references ...?title="the title"
  • {{pathparams}}
    • contains path parameters. Note that this requires your page to have the whole path as Page name. For example, a page named "/contacts/:name" can retrieve the path parameter :name using {{}}. Accessing the page with /contacts/john will put "john" into Note that the page name MUST start with a slash '/' in order for this to work.
  • {{credentials}}
    • For password protected pages it contains name and pass for an authenticated user on a Page using the #auth tag.
    • For pages using Auth0 integration it contains the decoded jwt object.

Creating hashmaps for site-wide settings

Sometimes it can be nice to use a Collection to store sitewide settings. In this case it is awkward and unreadable to access these data from an array: {{}}. Instead you can map the result of a query to a hashmap as follows:

      "settings": {
          "collection": "settings",
          "query": {},

You can now access the settings like this: {{settings.title}}.

Note that the key field (here: name) should be set to be unique.

Hosting a web site using Pages and

A database with Pages can be used to host a site. To do this, you need to create at least one Page and make it public. Now, go to the "Users and Settings" for your database. There you'll find the "Webhosting" tab and the instructions for hosting your Pages. The "Page name" sets up the default landing page.