Skip to main content

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.

Use 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.

The global navigation object provides web-standard navigation functionality. Access these properties and methods directly through the global navigation object to manage navigation within modal interfaces.

() => void
required

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.

required

Returns a NavigationHistoryEntry 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?: ) => Promise<void>
required

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.

The global window object provides control over the extension screen lifecycle. Access these properties and methods directly through the global window object to manage the modal interface.

() => void
required

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.

Examples

jsx

import { render } from "preact";

export default async () => {
render(<Extension />, document.body);
};

const Extension = () => {
const url = navigation.currentEntry.url;

if (url?.includes("ScreenTwo")) {
return (
<s-page heading="Screen Two Title">
<s-scroll-box>
<s-button onClick={() => navigation.navigate("ScreenOne")}>
Navigate to Screen One
</s-button>
<s-button onClick={() => navigation.back()}>Go back</s-button>
</s-scroll-box>
</s-page>
);
}

return (
<s-page heading="Screen One Title">
<s-scroll-box>
<s-button onClick={() => navigation.navigate("ScreenTwo")}>
Navigate to Screen Two
</s-button>
<s-button onClick={() => navigation.back()}>Go back</s-button>
</s-scroll-box>
</s-page>
);
};

  • 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 state parameter in navigation options to pass data between screens, maintaining workflow context and user progress across navigation changes.

  • 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.
Was this page helpful?