Directs the browser to navigate to the specified URL.
to() function navigates the browser to another web page.
The following link patterns are supported:
/localPageURL: Another page on your site.
/localPageURL#<corvid-element-id>: Another page on your site scrolled to the element with the specified ID. The element must be an element that supports the
/localPageURL?queryParam=value: Another page on your site with query parameters.
/: Your site's home page.
http(s)://<url>: An external web address.
wix:document://<location>: A document stored in the Media Manager.
mailto:<address>@<someplace.com>?subject=<subject>: An email.
tel:<phone number>: A phone number.
To find the local URL of a page on your site in the Editor:
- Regular page: See the SEO tab of the Page Settings panel.
Dynamic page: See the Page Info tab of the Page Settings panel for the URL structure. The actual URL used for navigation needs to contain values where the placeholders are.
For example, if the URL structure of your dynamic page looks like:
and you have an item with the title "Waffles", the local URL to that page is /Recipes/Waffles.
Router page: You cannot navigate directly to a specific router page. You can navigate to a URL with the router's prefix and the router code decides which page to route to.
to() function attempts to properly encode the URL parameter that
is passed to it. For example,
.../some page is encoded to
.../some%20page. However, some URLs do not have one unambiguous encoding.
In those cases it is up to you to encode the URL to reflect your intentions.
Because of these situations, it is a best practice to always encode URLs
before you pass them to the
Note that Wix URLs do not contain spaces. A page which has spaces in its
name has its spaces replaced with dashes (
-). Similarly, a dynamic page
whose URL contains the value of a field in your collection with spaces
has its spaces replaced with dashes (
function to(url: string): void
The URL of the page or website to navigate to.
This function does not return anything.
Was this helpful?