
Appifio Creator · Lesson EM06 · Easy · 3 route methods
add · remove · get - full structure
Only index.html runs by default. Easy: routes = client reads/writes routes.json (not a separate server action like Aura).
addRoute + an HTML handler file. Delete content → removeRoute.appifio_addRoute(routeKey, filePath, type?)Job: Map the URL segment after the app link name → a page file.
Params:
routeKey- e.g.article-about-aior nestedtag/javascriptfilePath- e.g.blog/detail.htmltype- optional, e.g.'blog','tag'(default null)
const r = await appifio_client.appifio_addRoute(
'article-about-ai',
'blog/detail.html',
'blog'
);
await appifio_client.appifio_addRoute('tag/javascript', 'blog/tag.html', 'tag');Returns: { success, message? }. Inside: read routes.json → edit → write back. Aura: route API + usually needs admin.
appifio_removeRoute(routeKey)await appifio_client.appifio_removeRoute('article-about-ai');Returns: { success }. Removes the line in routes.json. That URL 404s if nothing else maps it.
appifio_getRoutes()Job: Read the full map (JS already parsed for you).
const r = await appifio_client.appifio_getRoutes();
if (r.success) {
const routes = r.data.routes || {};
const fallback = r.data.fallback; // usually "index.html"
}Returns: { data: { routes: { [key]: { file, type?, enabled? } }, fallback? } } - no extra JSON.parse.
Absolute URLs (base tag)
Not a Storage method - a helper you attach on the page (avoids relative links breaking because of
function getAbsoluteUrl(path) {
let siteUrl = window.location.origin;
const apps = window.appifio?.global?.apps;
if (apps?.site_url) siteUrl = apps.site_url.replace(/\/$/, '');
let urlName = apps?.url_name
|| window.location.pathname.split('/').filter(Boolean)[0]
|| '';
return siteUrl + '/' + urlName + '/' + String(path).replace(/^\//, '');
}Next
EM07 - Helpers (full methods)
Internal navigation (same language)
Appifio Creator · User guide · EM06