Docsfrontbacked.js reference
On this page

Initialization and admin reference

Initialize pages and control admin edit mode.

Method signatures

js

Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →

Before you begin: Endpoint calls reference.

Initialization

Frontbacked.init(options) boots FQL for the current page. It parses state from the {STATE} comment or options.state, scans f-* bindings, fetches required server data, applies page access rules, wires SPA navigation, and renders the DOM.

OptionPurpose
endpointBase API path used for query, auth, and post requests. Defaults to /api.
debugShows extra FQL details in the browser console while you build.
stateOptional FQL state declaration object. When provided, it is used before the {STATE} HTML comment.
navigationIndicatorControls the built-in navigation progress bar. Pass false to turn it off, or { color, height, delay } to match your theme.

Use f-access and f-redirect-to on <body> to let Frontbacked gate pages without custom page code:

index.html

Frontbacked.admin.url(path) resolves the current site's admin URL from $siteInfo, falling back to /fb-admin. Frontbacked.admin.open(path, options) opens that URL, defaulting to a new tab with noopener,noreferrer.

Frontbacked.editMode.enable(options) enables page edit mode for admins with edit permission. The first enable in a browser shows a Frontbacked warning modal explaining that edit mode can change editable site text, images, links, and list content directly on the page; once the admin confirms, Frontbacked remembers that acceptance in the browser and does not show the warning again there. Frontbacked.editMode.disable() and Frontbacked.editMode.toggle() update $editMode and refresh the current render. Frontbacked.startEditMode(redirectTo = "/") and Frontbacked.exitEditMode() remain compatibility shortcuts.

Theme developers can use declarative admin controls without custom JavaScript:

index.html

When $auth is requested, Frontbacked also exposes the current user's site-admin capability:

index.html

$auth.admin.exists and $auth.isAdmin are true when the user is listed as a site admin. $auth.admin.permissions.read, .create, .edit, and .delete mirror the direct canRead, canCreate, canEdit, and canDelete flags.

Continue with State and schemas reference.