/** * An object used to manage the query segment of the current page's URL. * * Get hands-on experience with the URL query parameters on the [Hello Query Parameters](https://dev.wix.com/docs/coding-examples/getting-started/hello-world/hello-query-parameters) example page. */ interface QueryParams { /** * Adds query parameters to the current page's URL. * * Adds one or more query parameters to the current page's URL. * * The `add()` method can only be used when browser * [rendering](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/page-rendering/about-page-rendering) happens, * meaning you can only use it in frontend code after the page is ready. * * If a specified key already exists as a query parameter, the * newly specified value overwrites the key's previous value. * * Calling the `add()` method triggers `onChange()` * if it has been registered. * > **Note:** To retrieve the page's current query parameters, use the * `query` method. * @param toAdd - An object containing a `key:value` pair * for each query parameter to add to the URL, where the object's * keys are the query parameter keys and the object's values * are the corresponding query parameter values. * @requiredField toAdd */ add(toAdd: object): Promise; /** * Removes query parameters from the current page's URL. * * Removes 1 or more query parameters to the current page's URL. * * The `remove()` method can only be used when browser * [rendering](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/page-rendering/about-page-rendering) happens, * meaning you can only use it in frontend code after the page is ready. * * If a specified key doesn't exist as a query parameter, it * is ignored. * * Calling the `remove()` method triggers `onChange()` * if it has been registered. * > **Note:** To retrieve the page's current query parameters, use the * `query` method. * @param toRemove - List of keys to remove. * @requiredField toRemove */ remove(toRemove: string[]): Promise; } /** * Adds query parameters to the current page's URL. * * Adds one or more query parameters to the current page's URL. * * The `add()` method can only be used when browser * [rendering](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/page-rendering/about-page-rendering) happens, * meaning you can only use it in frontend code after the page is ready. * * If a specified key already exists as a query parameter, the * newly specified value overwrites the key's previous value. * * Calling the `add()` method triggers `onChange()` * if it has been registered. * > **Note:** To retrieve the page's current query parameters, use the * `query` method. * @param toAdd - An object containing a `key:value` pair * for each query parameter to add to the URL, where the object's * keys are the query parameter keys and the object's values * are the corresponding query parameter values. * @requiredField toAdd */ declare function add(toAdd: object): Promise; /** * Removes query parameters from the current page's URL. * * Removes 1 or more query parameters to the current page's URL. * * The `remove()` method can only be used when browser * [rendering](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/page-rendering/about-page-rendering) happens, * meaning you can only use it in frontend code after the page is ready. * * If a specified key doesn't exist as a query parameter, it * is ignored. * * Calling the `remove()` method triggers `onChange()` * if it has been registered. * > **Note:** To retrieve the page's current query parameters, use the * `query` method. * @param toRemove - List of keys to remove. * @requiredField toRemove */ declare function remove(toRemove: string[]): Promise; type queryParamsSdkModuleContext_QueryParams = QueryParams; declare const queryParamsSdkModuleContext_add: typeof add; declare const queryParamsSdkModuleContext_remove: typeof remove; declare namespace queryParamsSdkModuleContext { export { type queryParamsSdkModuleContext_QueryParams as QueryParams, queryParamsSdkModuleContext_add as add, queryParamsSdkModuleContext_remove as remove }; } type Methods$1 = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const queryParamsContext: Methods$1; /** * An object containing information about a location. */ interface Location { /** * Location path. * @requiredField path */ path: string; } /** * An object containing navigation and scrolling options. */ interface NavOptions { /** * Whether the page scrolls to the top when navigating to the specified URL for a Wix page. Defaults to `false`. When `true`, the page remains at the same Y-axis position as the previously-viewed page. This setting doesn't affect scrolling for external URLs. */ disableScrollToTop?: boolean; } /** * Handles location change events. * @param event - The new location. * @requiredField event * @servicePath wix-location-frontend.Location */ type LocationChangeHandler = (event: Location) => void; /** * Gets the base URL of the current page. * * Premium sites: * ![Premium site baseUrl](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_baseurl.png "Premium site baseUrl") * * Free sites: * ![Free site baseUrl](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_baseurl.png "Free site baseUrl") * @readonly */ declare function baseUrl(): Promise; /** * Gets the path of the current page's URL. * * The path for a regular page is after the `baseUrl`. * If the page is a dynamic page or a router page, the `prefix` appears after the base URL, before the path. * * * Premium sites: * Path for a regular page, without a prefix: ![Premium site path](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_path.png "Premium site path") * Path for a dynamic or router page with a prefix: ![Premium site path](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_path_with_prefix.png "Premium site path with a prefix") * * Free sites: * Path for a regular page, without a prefix: ![Free site path](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_path.png "Free site path") * Path for a dynamic or router page with a prefix: ![Free site path](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_path_with_prefix.png "Free site path") * @readonly */ declare function path(): Promise; /** * Gets the prefix of a dynamic page's or router page's URL. * * Only dynamic pages and router pages have a prefix. The value of the * `prefix` property for other page types is always `undefined`. * * Premium sites: * ![Premium site prefix](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_prefix.png "Premium site prefix") * * Free sites: * ![Free site prefix](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_prefix.png "Free site prefix") * * To learn more about dynamic page prefixes, see [About URL Prefixes and Page Grouping of Dynamic Pages](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/dynamic-pages/making-dynamic-page-urls-meaningful-with-prefixes). * * To learn more about router page prefixes, see [About Routers](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/routers/about-routers#url-prefix). * @readonly */ declare function prefix(): Promise; /** * Gets the protocol of the current page's URL. * * Premium sites: * ![Premium site protocol](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_protocol.png "Premium site protocol") * * Free sites: * ![Free site protocol](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_protocol.png "Free site protocol") * @readonly */ declare function protocol(): Promise; /** * Gets an object that represents the query segment of the current page's URL. * * Premium sites: * ![Premium site query](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_query.png "Premium site query") * * Free sites: * ![Free site query](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_query.png "Free site query") * @readonly */ declare function query(): Promise; /** * Gets the full URL of the current page. * * Premium sites: * ![Premium site URL](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_premium_url.png "Premium site URL") * * Free sites: * ![Free site URL](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_url_free_url.png "Free site URL") * @readonly */ declare function url(): Promise; /** * Adds an event handler that runs when an application page's URL changes. * * The event handler set by the `onChange()` method runs when the location changes * but the change doesn't trigger navigation. This situation occurs when navigating between * subitems on a page that's managed by a full-page application. * * For example, a store product page is a full-page application. When a product page's path * changes because it's switching between items, no actual navigation is taking place. You * can use the `onChange()` event handler to determine when a new product is displayed and * perform any necessary partial updates on the current page. * * The `onChange()` method can only be used when browser * [rendering](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/page-rendering/about-page-rendering) happens, * meaning you can only use it in frontend code after the page is ready. * * To determine if a page is managed by a full-page application, use the Site API's * `currentPage` property or `getSiteStructure()` * method to retrieve a `StructurePage` object that * corresponds to the page. If the object contains an `applicationId` value, then the * page is managed by a full-page application. * @param handler - The method to call when the location changes. * @requiredField handler * @servicePath wix-location-frontend.LocationChangeHandler */ declare function onChange(handler: LocationChangeHandler): Promise; /** * Directs the browser to navigate to the specified URL. * * The `to()` method navigates the browser to another web page. * * The `to()` method can only be used when browser * [rendering](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/page-rendering/about-page-rendering) happens, * meaning you can only use it in frontend code after the page is ready. * * The following link patterns are supported: * * + `/localPageURL`: Another page on a site. * + `/localPageURL#`: Another page on a site scrolled to the * element with the specified ID. The element must be an element that supports * the `scrollTo` method. * + `/localPageURL?queryParam=value`: Another page on a site with query parameters. * + `/`: A site's home page. * + `http(s)://`: An external web address. * + `wix:document://`: A document stored in the Media Manager. * + `mailto:@?subject=`: An email. * + `tel:`: A phone number. * * * To find the local URL of a page on a 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 a dynamic page looks like: * * ![Dynamic Page URL](https://wixmp-833713b177cebf373f611808.wixmp.com/images/velo-images/media_dynamic_url.png "Dynamic Page URL") * * and you have an item with the title "Waffles", the local URL to that page * is /Recipes/Waffles. * + Router page: You can't 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. * * By default, when navigating to a new URL for a Wix page, the page scrolls to the top. Set * the `disableScrollToTop` navigation parameter property to `true` if you want the * page to remain at the current Y-axis position as the previously-viewed page. * * The `to()` method attempts to properly encode the URL parameter that * is passed to it. For example, `.../some page` is encoded to * `.../some%20page`. However, some URLs don't have 1 unambiguous encoding. * In those cases it's up to you to encode the URL to reflect your intentions. * Because of these situations, it's a best practice to always encode URLs * before you pass them to the `to()` method. * * Note that Wix URLs don't 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 a collection with spaces * has its spaces replaced with dashes (`-`). * * > **Note:** The `to()` method doesn't work while previewing a site. * @param url - The URL of the page or website to navigate to. * @requiredField url * @param options - Options to use when navigating to the specified URL, such as scrolling options. * @servicePath wix-location-frontend.NavOptions */ declare function to(url: string, options?: NavOptions): Promise; declare const locationSdkModuleContext_baseUrl: typeof baseUrl; declare const locationSdkModuleContext_onChange: typeof onChange; declare const locationSdkModuleContext_path: typeof path; declare const locationSdkModuleContext_prefix: typeof prefix; declare const locationSdkModuleContext_protocol: typeof protocol; declare const locationSdkModuleContext_query: typeof query; declare const locationSdkModuleContext_to: typeof to; declare const locationSdkModuleContext_url: typeof url; declare namespace locationSdkModuleContext { export { locationSdkModuleContext_baseUrl as baseUrl, locationSdkModuleContext_onChange as onChange, locationSdkModuleContext_path as path, locationSdkModuleContext_prefix as prefix, locationSdkModuleContext_protocol as protocol, locationSdkModuleContext_query as query, locationSdkModuleContext_to as to, locationSdkModuleContext_url as url }; } type Methods = { [P in keyof T as T[P] extends Function ? P : never]: T[P]; }; declare const locationContext: Methods; export { locationContext as location, queryParamsContext as queryParams };