Navigation methods
There are three primary ways to navigate between pages in your app.Using the PageLink component
ThePageLink component is the primary way to create clickable links to other pages within your app.
PageLink component supports the following props:
to(string): The path to navigate to (e.g.,"/","/docs")params(object): Query parameters to include in the URL
The
Link component from @hubspot/ui-extensions should only be used for external URLs. Use PageLink for navigating between pages within your app.Using PageHeader actions
Page header actions support linking to app pages usingPageLink components:
PageHeader.PrimaryAction and PageHeader.SecondaryActions can only contain PageHeader.PageLink (for internal pages) or PageHeader.Link (for external URLs) components.Programmatic navigation
You can navigate programmatically using thenavigateToPage action from the extension context:
navigateToPage function accepts an options object with:
to(string, required): The path to navigate toparams(object, optional): Query parameters to include
Linking with path parameters
When your routes include path parameters (e.g.,/view-contact/:contactId), you can pass parameter values through the params object. The routing system will automatically substitute matching parameter names into the URL path.
Basic path parameter linking
https://app.hubspot.com/app/{HubID}/{appId}/view-contact/123
The contactId parameter matches the :contactId path parameter, so it gets substituted into the path.
Mixing path and query parameters
When you provide multiple parameters, the routing system intelligently separates them:https://app.hubspot.com/app/{HubID}/{appId}/view-contact/123?tab=activity
Multiple path parameters
You can link to routes with multiple path parameters by including all matching parameters:https://app.hubspot.com/app/{HubID}/{appId}/deals/456/notes/789?highlightSection=comments
How parameter substitution works
The routing system follows these rules when generating URLs:-
Matching parameters go into the path: If a parameter name matches a path parameter placeholder (e.g.,
contactIdmatches:contactId), it replaces that placeholder in the URL. - Non-matching parameters become query parameters: Any parameters that don’t match path parameter names are added to the query string.
-
Parameter order doesn’t matter: The system will correctly match parameters regardless of the order they appear in the
paramsobject.
Programmatic navigation with path parameters
The same substitution rules apply when usingnavigateToPage:
For details on how to access parameters in your page components using
usePageRoute, including parameter limitations and best practices, see the Accessing route information section in the routing guide.