---
sourceDocument: Brazil Build or modify applications
sourceDocumentLink: https://www.servicenow.com/docs/r/application-development

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# Lux Page variants

# Lux Page variants {#ariaid-title1}

Release version: Brazil  
Updated September 29, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 6 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Lux Page variants

Lux Page variants enable ServiceNow customers to define multiple structurally different pages that share the same route but serve different audiences, such as different user roles.
Instead of embedding role checks within a single render method, page variants allow authors to create distinct page modules with unique widgets, layouts, and loaders.
This pattern is ideal when you need deliberate, authored variations rather than merely hiding sections conditionally.
Show full answer Show less  
A page variant setup consists of a base page at the normal route and one or more candidate pages placed under a dedicated `variants/` folder. Each candidate can be gated by roles or access control lists (ACLs) and ranked to determine serving priority. Variants dynamically resolve per request based on the user's identity and permissions.

## Key Features

* **Route Sharing:** All variant pages under `variants/` resolve to the same route as their base page, allowing multiple page modules to claim the same URL.
* **Gating and Ranking:** Use decorators such as `@acl()` to restrict access by roles or ACLs, and `@order()` to prioritize variants; lower order values win.
* **Dynamic Resolution:** The system evaluates all candidates matching a route, sorts by specificity and order, then selects the first accessible variant per the user's roles and ACL checks.
* **Switching Between Variants:** Two UI components---`<aiux-page-variant-switcher>` for viewers and a config editor picker for admins---allow switching among accessible variants. Switching triggers a full server-side route resolution, preserving unsaved work with dirty-state guards.
* **Configuration Records:** Each variant corresponds to a `sysaixpage` record with fields for variant name, order, and active status, enabling admins to disable variants without deletion.
* **Backward Compatibility:** The older `collections/` folder name is deprecated, and both `collections/` and `variants/` cannot coexist in the same folder.

## Practical Application for ServiceNow Customers

By leveraging Lux Page variants, you can create tailored user experiences for different roles or audiences on the same URL without complex conditional rendering. This improves maintainability and clarity of your UI code by separating concerns into distinct page modules.

When configuring variants:

* Use `@acl()` decorators to enforce role-based access and ensure gated variants have higher order values than any ungated fallback to prevent shadowing.
* Maintain a fallback base page with default order (100) or higher to serve users without special roles.
* Use the provided UI switchers during editing or as part of the viewer experience to select among available variants.
* Edit variant order and active status directly on the `sysaixpage` records since no admin UI is provided for these tasks.

Ensure your page folder structure follows the required conventions, placing variants in `variants/` subfolders next to the base page, and avoid mixing deprecated folder names.

## Outcome

Implementing Lux Page variants enables dynamic, role-aware page delivery under a unified route, enhancing user experience personalization and simplifying page management in ServiceNow applications. This approach supports live per-request resolution, allowing identity changes mid-session to reflect immediately on the next request, and provides seamless variant switching controls for both viewers and authors.  
A page collection lets more than one page module claim the same route. Lux determines which one to serve, per request, per user, instead of you branching a single `render()` on role checks.

Use a page collection when a route needs a structurally different page for different audiences (different widgets, different layout, different loader), not just a conditionally hidden section. A hidden section is simpler to
express as a widget ACL or a reactive property.

Page variants make it a deliberate, authored pattern. A variant is one or more candidate pages in a _variants/ folder, plus an optional base page at the normal route. Each sibling is optionally gated by role
or access control list (ACL), and ranked by an explicit order.  
Note:  
There's no admin interface for reordering or disabling a page variant; order and active are edited directly on the installed `sys_aix_page` record.

## The _collections/ convention {#page-collections__page-collections-the-collections-convention}

Put a base page at the normal route, then add a _variants/ sibling folder next to it with one subfolder per candidate:

    pages/dashboard/
    ├── page.js                    ← base page, order 100 (default), no ACL
    └── _variants/
        └── admin/
            └── page.js            ← candidate, ranked ahead of the base page

_variants/ is reserved and contributes no route segment of its own. Every page.js/page.ts under it, at any nesting depth, resolves to the same route as the
sibling base page. A _variants/ folder that contains no page.js/page.ts fails the build. A base page next to it is optional; without one, the route comes from
the parent folder.

The older folder name, _collections/, still builds but logs a deprecation warning. A folder that contains both _variants/ and _collections/ fails the build.

## Declaring a candidate {#page-collections__page-collections-declaring-a-candidate}

Gate and rank a candidate with two build-time decorators from `@servicenow/aiux-components-core`:

    // pages/dashboard/_variants/admin/page.js
    import {html} from 'lit';
    import {customElement} from 'lit/decorators.js';
    import {AIUXElement, decorators} from '@servicenow/aiux-components-core';

    const {acl, order} = decorators;

    @customElement('collections-demo-dashboard-admin-page')
    @order(10)
    @acl([{decision: 'allow_if', roles: ['admin']}])
    export default class DashboardAdminPage extends AIUXElement {
      render() {
        return html`<h1>Dashboard (admin)</h1>`;
      }
    }

The decorators for gating and ranking a collection candidate are described in the following table.
{#page-collections__table-collection-candidate-decorators__entry__2}

| Decorator | Effect |
|-|-|
| `@order(N)` | Integer; lower wins. A page with no `@order()` gets the default, 100 (pages contributed by an extension default to 10). |
| `@acl([{decision?, roles?, securityAttribute?, id?}])` | `decision` is `'allow_if'` (the default) or `'deny_unless'`. Each rule needs a non-empty `roles` array of role names, a non-empty `securityAttribute` string, or both. `id` is optional. A rule set made only of `deny_unless` rules fails the build. The build emits one ACL record per rule. |
[Table 1. Variant candidate decorators]

{#page-collections__table-collection-candidate-decorators}  
Warning:  
An ungated candidate must not sort ahead of gated siblings, or it wins for everyone. A missing ACL record is read leniently, accessible to all, so an undecorated (or `@order()`-only) page with a lower order than its gated siblings permanently shadows them. Leave an intentional fallback page at the default order (100) or higher.

`@acl()` and a legacy `@roles()` decorator are mutually exclusive for a variant candidate. A page carrying both still gets its ACL record generated, but only the `roles` check runs
during resolution.

## How resolution works {#page-collections__page-collections-how-resolution-works}

1. Every `sys_aix_page` candidate whose `path_pattern` matches the requested path is collected.
2. Candidates are sorted by URL specificity first, then by `order` ascending; a base page and its _variants/ siblings share one route, so `order` alone decides among them.
3. Each candidate is checked, in that sorted order, by whichever access mechanism its own record declares. A legacy `roles` check fails closed on an infrastructure error. An ACL check runs against the candidate's own ACL records and fails open, so an undecorated page with no ACL record is accessible to everyone.
4. The first accessible candidate wins and is served, unless the request names an accessible sibling (the viewer's switcher choice or the URL), which is served instead. The rest are offered as alternatives, which is what the two pickers in the Switching between siblings section render from.

Variant candidates are resolved live, per request. A route with more than one page variant doesn't use the identity-blind on-disk fast path, so switching identity mid-session picks up the correct candidate on the next
request.

## Switching between siblings {#page-collections__page-collections-switching-between-siblings}

Two surfaces render the sibling pool, for two different audiences.
{#page-collections__table-sibling-pickers__entry__3}

| Aspect | `<aiux-page-variant-switcher>` | The config editor's collection picker |
|-|-|-|
| Package | `@servicenow/aiux-components-nav` | `@servicenow/aiux-components-config-editor` |
| Audience | Viewer | Admin, while configuring |
| Mount | `horizontal-contextual-nav`, through `nav-layout` | The config editor's toolbar |
| Gate | `features.pageVariantSwitcher`, default `true`, and the `aiux.nav.page_variant_switcher.enabled` system property, default `true`; both must allow it | Only while editing |
[Table 2. Sibling pickers]

{#page-collections__table-sibling-pickers}

Switching page variants while configuring is an authoring action rather than a viewer action, so the editor gets its own control labeled "Editing:" followed by the page variant title. An app that wants only the authoring
control turns the shell control off per app:

    navLayoutContext.set({
      ...(navLayoutContext.get() ?? {}),
      features: {...(navLayoutContext.get()?.features ?? {}), pageVariantSwitcher: false}
    });
    await super.loader(ctx);

Warning:  
NavLayout.loader takes only `ctx`. A second options argument is silently dropped, so feature opt-outs must be written onto `navLayoutContext` before `super.loader` runs, as the preceding example shows.

Both pickers run the switch through the router's beforeNavigate pipeline rather than assigning `location.href`, so a dirty-state guard goes first and switching can't silently discard
unsaved work. Either way the sibling is chosen during server route resolution; a switch re-resolves the route server-side rather than swapping client state.

The config editor's entry point appears for config admins when the page has a configurable component or more than one page variant.

## Schema {#page-collections__page-collections-schema}

`sys_aix_page` carries three fields for this feature.
{#page-collections__table-collection-fields-on-sys-aix-page__entry__4}

| Column | Type | Default | Purpose |
|-|-|-|-|
| `variant_name` | string |   | Identifies a collection page relative to its base page. The build derives it from the folder segment(s) under _variants/\<name\>/ and writes it onto the record (e.g. _variants/admin/page.js → `admin`); no manual authoring step. |
| `order` | integer | `100` (`10` for extension pages) | Evaluation precedence when multiple candidates match the same route. Lower wins. |
| `active` | boolean | `true` | Lets an admin disable a page variant without deleting it. |
[Table 3. Variant fields on sys_aix_page]

{#page-collections__table-collection-fields-on-sys-aix-page}

There's no `parent_page_id` link back to the base page and no `variant_name`/`is_default` flag; a page variant is identified purely by sharing its base page's
`path_pattern`.

## How a page becomes sys_aix_page in general {#page-collections__page-collections-how-a-page-becomes-sys-aix-page-in-general}

Outside the variants feature specifically, every page under pages/ maps to a `sys_aix_page` record the same way.
{#page-collections__table-page-to-record-derivation__entry__3}

| Source | Field | Derivation |
|-|-|-|
| Folder path under pages/ | `path_pattern` | `[param]` converts to `:param`; the page.js/page.ts filename is not part of the route |
| `@title()` decorator | `title` | Decorator value on the default export class |
| `@global(false)` decorator | `private_experience` | Restricts the page to the app's own experience. Build error if aiux.json has no `basename` |
| `@roles([...])` decorator | `roles` | Legacy role gate, distinct from `@acl()` |
[Table 4. Page-to-record derivation]

{#page-collections__table-page-to-record-derivation}
**Related tasks**   

* [Create a page](https://www.servicenow.com/docs/_evQSbH3TwJw0TF5_xzn4Q "Add a page to a Lux app. A page is a Lit web component that Lux registers as a route based on where you put its file.")  
**Related topics**   

* 

