usePageLocation

Deprecated

This hook is deprecated. For more information, see Migrating from dashboard-react.

A React hook that provides access to the currently rendered dashboard page's location data. A component using this hook re-renders whenever the current page's URL changes.

Signature

Copy

Returns

A PageLocation object:

Copy
NameTypeDescription
pageIdstringID of the current page.
pathnamestringAny parts of the current URL path appended to the page's full URL path. Learn more.
searchstringOptional. The current URL's query string.
hashstringOptional. The current URL's fragment identifier.

About pathname

The value of pathname is any part of the URL path that comes after the route to the current dashboard page.

For third-party app dashboard pages, this is anything appended to the URL after the Relative route value that you set when creating the dashboard page extension in the Wix Developers Center.

Examples

In order to set up a dashboard client for React, please refer to the setup guide.

Client side routing

In this example, we use the pathname returned by usePageLocation() to define which view the component rendered.

Copy
Did this help?