Skip to main content

Navigation API
APIs

() => void
required

The back() method of the Navigation interface navigates to the previous entry in the history list.

required

The currentEntry read-only property of the Navigation interface returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.

(url: string, options?: ) => Promise<void>
required

The navigate() method navigates to a specific URL, updating any provided state in the history entries list.

Was this section helpful?

Examples of using the Navigation API

Was this section helpful?

Navigate between two screens

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>
);
};