Updating Navigation Drawer at Runtime
The Navigation Drawer Bridge lets you update the drawer's header and navigation items at runtime from your website JavaScript. This is useful when the drawer content should reflect the user's current state — for example, personalizing the header title and showing account-specific menu items after login.
Opening and Closing the Drawer
You can programmatically open or close the Navigation Drawer from your webpage JavaScript.
Open the drawer:
appilix.postMessage(JSON.stringify({
type: "drawer_open"
}));Close the drawer:
appilix.postMessage(JSON.stringify({
type: "drawer_close"
}));Updating the Drawer
appilix.postMessage(JSON.stringify({
type: "update_settings",
updates: {
modules: {
drawer_nav: {
settings: {
header_title: "App Name",
header_sub_title: "Slogan of the App",
items: [
{
icon: "e88a",
title: "Home",
action: "https://example.com"
},
{
icon: "e88e",
title: "About",
action: "https://example.com/about"
},
{
icon: "e0be",
title: "Contact",
action: "https://example.com/contact"
}
]
}
}
}
}
}));Updatable Properties
| Property | Description |
|---|---|
header_title | The main title shown in the drawer header |
header_sub_title | The secondary line shown below the title in the header |
items | Array of navigation items to replace the current drawer list |
All three properties are optional — you can update any combination of them in a single call.
Item Properties
| Property | Description |
|---|---|
icon | Material Icon codepoint in hex (Outlined style) |
title | Label shown next to the icon |
action | URL to open when the item is tapped |
The icon value is a hex codepoint from Google Material Icons (Outlined). For example, the Home icon (home) has the codepoint e88a.
Common Use Cases
Personalize the drawer when a user logs in:
appilix.postMessage(JSON.stringify({
type: "update_settings",
updates: {
modules: {
drawer_nav: {
settings: {
header_title: "Welcome, John",
header_sub_title: "john@example.com",
items: [
{
icon: "e88a",
title: "Home",
action: "https://example.com"
},
{
icon: "e7fd",
title: "Dashboard",
action: "https://example.com/dashboard"
},
{
icon: "e7ff",
title: "Profile",
action: "https://example.com/profile"
},
{
icon: "e9ba",
title: "Logout",
action: "https://example.com/logout"
}
]
}
}
}
}
}));Revert to defaults after logout:
appilix.postMessage(JSON.stringify({
type: "update_settings",
updates: {
modules: {
drawer_nav: {
settings: {
header_title: "App Name",
header_sub_title: "Slogan of the App",
items: [
{
icon: "e88a",
title: "Home",
action: "https://example.com"
},
{
icon: "e88e",
title: "About",
action: "https://example.com/about"
},
{
icon: "e0be",
title: "Contact",
action: "https://example.com/contact"
}
]
}
}
}
}
}));For a general introduction to the JavaScript Bridge, see the Overview article.