Velo is a full-stack development platform that empowers you to rapidly build, manage and deploy professional web apps.
Using Velo you can create routers that allow you to take complete control when handling incoming requests to your site. To do so, you set up a router to receive all incoming requests with a specified prefix and define the logic of what to do when a request with that prefix is received. You decide what actions to perform, what response to return, where to route the request, and what data to pass to the page.
You might want to use a router to:
The API reference for routers can be found here.
When creating a router, you choose which requests will get handled by the router based on a URL prefix that you specify. All incoming requests with that URL prefix will be sent to your router for handling. The URL prefix is also used as the router's name.
The prefix is the part of the URL shown in bold in the following examples:
Your routing logic is defined in the routers.js file, which can be found in the Backend section of your Code Files in the Velo Sidebar. There are two main functions that are the entry points to your router.
They are named with the following convention:
function is where page requests with the defined prefix are sent. The router receives a WixRouterRequest object containing information about the incoming request. The function then decides what to do with the request and returns the appropriate
. Typically, the
function will decide which page to show (if any) and what data to pass to the page. The response is then sent using the
function is where sitemap requests are handled. You can use this function to make sure search engines can find the links to your router's pages. Each
includes information about a page, such as its URL, title, and name.
function is also used to populate the items preview widget, allowing you to switch between URLs in preview mode.
function may choose to send data to the pages it routes to. You can access that data in the frontend page code using the
function of the wix-window module.
Previously published at https://support.wix.com/en/article/velo-about-routers
Create your free account to unlock your custom reading experience.