Navigation API
The Navigation API provides web-standard navigation functionality for POS UI extensions, allowing you to navigate between URLs, manage navigation history, and handle navigation events within modal interfaces. The API is available globally as the navigation object and follows web platform standards.
Each screen runs in its own isolated sandbox, so module-level variables and closures aren't shared across navigations. To pass data between screens, use the state option in navigation.navigate() or the Storage API.
Anchor to Use casesUse cases
- Multi-screen workflows: Implement workflows with URL-based navigation and browser history support.
- Wizard interfaces: Build wizard-style interfaces allowing forward and backward navigation.
- Deep linking: Create deep-linkable modal states that can be bookmarked or shared.
- Navigation events: Handle navigation events to save progress or trigger cleanup.
Anchor to PropertiesProperties
The navigation object provides navigation controls for extension modals. Access the following properties on navigation to navigate between screens, manage navigation history, and handle navigation events.
- () => void() => voidrequiredrequired
Navigates to the previous entry in the history list. Use for implementing back buttons, breadcrumb navigation, or allowing users to return to previous screens in multi-step workflows.
- NavigationHistoryEntryNavigationHistoryEntryrequiredrequired
Returns a
object representing the location the user is currently navigated to. Use to access current URL, navigation state, or implement navigation-aware functionality based on the current location.- (url: string, options?: NavigationNavigateOptions) => Promise<void>(url: string, options?: NavigationNavigateOptions) => Promise<void>requiredrequired
Navigates to a specific URL, updating any provided state in the history entries list. Returns a promise that resolves when navigation is complete. Use for programmatic navigation between screens, implementing custom navigation controls, or deep-linking to specific modal states.
NavigationHistoryEntry
Represents a single entry in the navigation history stack. Contains the URL and unique identifier for tracking navigation state and implementing history-based navigation.
- getState
Returns a clone of the available state associated with this history entry. Use to retrieve navigation state data that was passed during navigation or to implement state-based navigation logic.
() => unknown - key
A unique, UA-generated value that represents the history entry's slot in the entries list rather than the entry itself. Use for tracking navigation history or implementing navigation-based logic.
string - url
The URL of this history entry. Returns `null` if no URL is associated with the entry. Use for URL-based navigation logic, deep-linking, or displaying current location information.
string | null
NavigationNavigateOptions
Specifies configuration options for navigation operations. Allows passing state data that persists across navigation transitions.
- state
Developer-defined information to be stored in the associated `NavigationHistoryEntry` once the navigation is complete, retrievable using `getState()`. Use to pass data between navigation states or implement stateful navigation workflows.
unknown
Anchor to WindowWindow
The global window object provides control over the extension modal lifecycle. Access these properties and methods directly through the global window object to manage the modal interface programmatically.
- Anchor to closecloseclose() => void() => voidrequiredrequired
Closes the extension screen and dismisses the modal interface. Use to programmatically close the modal after completing a workflow, canceling an operation, or when user action is no longer required. This provides the same behavior as the user dismissing the modal through the UI.
Anchor to Best practicesBest practices
- Use URL-based navigation: Implement URL-based navigation patterns that allow for deep-linking, bookmarking, and intuitive browser-like navigation within your modal workflows.
- Manage navigation state effectively: Use the
stateparameter in navigation options to pass data between screens, maintaining workflow context and user progress across navigation changes.
Anchor to LimitationsLimitations
- The Navigation API is only available in action (modal) targets and can't be used in action (menu item), block, or tile targets that don't support multi-screen navigation.
- Navigation state is limited to serializable data and can't contain functions, complex objects, or circular references.