Navigation
The API provided to extensions to navigate to extensions or host page.
Navigation API for all extensions. Refer to supported protocols
- (type: "currententrychange", cb: (event: NavigationCurrentEntryChangeEvent) => void) => void(type: "currententrychange", cb: (event: NavigationCurrentEntryChangeEvent) => void) => voidrequiredrequired
- NavigationHistoryEntryNavigationHistoryEntryrequiredrequired
The currentEntry read-only property of the Navigation interface returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.
- NavigateFunctionNavigateFunctionrequiredrequired
The navigate() method navigates to a specific URL, updating any provided state in the history entries list.
- (type: "currententrychange", cb: (event: NavigationCurrentEntryChangeEvent) => void) => void(type: "currententrychange", cb: (event: NavigationCurrentEntryChangeEvent) => void) => voidrequiredrequired
- (options: NavigationUpdateCurrentEntryOptions) => void(options: NavigationUpdateCurrentEntryOptions) => voidrequiredrequired
The updateCurrentEntry() method of the Navigation interface updates the state of the currentEntry; used in cases where the state change will be independent of a navigation or reload.
NavigationCurrentEntryChangeEvent
The NavigationCurrentEntryChangeEvent interface of the Navigation API is the event object for the currententrychange event, which fires when the Navigation.currentEntry has changed.
- from
Returns the NavigationHistoryEntry that was navigated from.
NavigationHistoryEntry - navigationType
Returns the type of the navigation that resulted in the change.
NavigationTypeString
NavigationHistoryEntry
The NavigationHistoryEntry interface of the Navigation API represents a single navigation history entry.
- getState
Returns a clone of the available state associated with this history entry.
() => unknown - key
Returns the key of the history entry. This is a unique, UA-generated value that represents the history entry's slot in the entries list rather than the entry itself.
string - url
Returns the URL of this history entry.
string | null
NavigationTypeString
An enumerated value representing the type of navigation.
'push' | 'replace' | 'traverse'NavigateFunction
NavigationUpdateCurrentEntryOptions
- state
unknown
Examples
Extension.jsx
Default
import '@shopify/ui-extensions/preact'; import {render} from 'preact'; export default async () => { render(<Extension />, document.body); }; function Extension() { return ( <s-button onClick={() => { navigation.navigate('extension://orders'); }} > Navigate to orders path </s-button> ); }