The Pages API describes a Wix site's pages. Use it to build navigation, such as a breadcrumb trail, from the pages a Wix user actually has, and to adapt a component to the page it's shown on.
With the Pages API, you can:
- Retrieve every page on the site, with its title, slug, path, parent page, and whether it's a popup.
- Retrieve the page that's currently displayed, and check whether it's a popup.
- Retrieve the main page, which is the page a site visitor reaches at the site root URL.
- Identify the pages that an installed app adds, by the app's ID and the app page ID.
It's important to note the following points before starting to code:
- The values can change while the page is open, for example when a Wix user edits pages, or moves to a different page, in the editor. Read them while a component renders, so the component updates when they change.
- Main page: The page a visitor reaches at the site root. A Wix user chooses which page this is.
- Slug: The page's own segment of its URL, such as
spring in collections/spring. It's unique across the site, but a Wix user can change it.
- Popup: A page that opens over the page a visitor is already on, rather than replacing it.
- App page: A page that an app installed on the site adds to it, such as the Bookings checkout page. Its app page ID stays the same across sites, even though a Wix user can change the page's path.
To use the API, install the @wix/site-service-pages package:
Import any type shown in these docs from @wix/site-service-pages/types:
In a React component, resolve the service with the useService hook: