> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: About Routers ## Article: About Routers ## Article Link: https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/routers/about-routers.md ## Article Content: # About Routers Wix gives you the ability to display multiple items from your data collection with [dynamic pages](https://support.wix.com/en/article/cms-about-dynamic-pages). In your site editor, you see only one dynamic item page, but visitors to your site see multiple pages with the same design, each rendering a different item from your collection. You can set a unique URL for each of these item pages. Behind the scenes, Wix creates a router that handles incoming requests to the dynamic page and directs the client to the correct URL. Wix also handles SEO for you in the background. However, if you prefer to handle requests with your own custom logic, you can create your own router. With your own router, you have full control over how your site handles incoming requests, as well as the SEO for dynamic pages. 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: * Display a dynamic page using content from any data source. * Customize your URLs to make them more meaningful and yield better SEO results. * Authenticate users and then display content just for them. * Return custom HTTP response codes. In the following sections, we review the important components of creating a router for your site. ## Supported IDEs You can create routers using: * The [editor](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/velo-workspace/workspaces/wix-studio-working-with-the-code-panel.md) (Wix Studio and Wix Editor). * The [Wix IDE](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/velo-workspace/wix-ide/wix-studio-about-the-wix-ide.md). * Your [local IDE](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/git-integration-wix-cli/about-git-integration-wix-cli.md) (Wix Studio and Wix Editor). ## URL prefix When you create a router, you specify a URL path prefix that follows your site's domain name. The prefix is the part of the URL shown in angle brackets in the following examples: * Premium site: `https://domain.com//category/item` * Free site: `https://user.wixsite.com/yoursite//category/item` This URL prefix determines which incoming requests your router handles. If your site receives a request with the specified prefix, it sends that request to your router for handling. The URL prefix is also used as the name for the router functions and pages. ## Routing code When you create the first router on your site, Wix automatically adds a file called `routers.js` to your site's backend folder. In this file, you write all your logic for handling incoming requests. `routers.js` contains two functions that are the entry points to your router. They are named with the following convention: * `_Router(request)` * `_Sitemap(sitemapRequest)` Note that if you add any more routers to the site, Wix adds the functions for them in the same file. For example, if you add `myRouter1` and `myRouter2` to the site, you'll see the following functions in your `routers.js` file: * `myRouter1_Router(request)` * `myRouter1_Sitemap(sitemapRequest)` * `myRouter2_Router(request)` * `myRouter2_Sitemap(sitemapRequest)` You then write the logic for each router in its respective set of functions. ### router() The [`router()`](https://dev.wix.com/docs/velo/api-reference/wix-router/introduction.md) function is where the site sends page requests with the defined prefix. The router receives a `WixRouterRequest` object containing information about the incoming request, such as the full URL used to reach the router, and where the request came from. The function then decides what to do with the request and returns the appropriate `WixRouterResponse`. Typically, the `router()` function will decide which page to show (if any) and what data to pass to the page. The response is then sent using the `forbidden()`, `notFound()`, `ok()`, `redirect()`, or `sendStatus()` functions. ### sitemap() Your sitemap is what Google uses to find your site's pages. Pages on your site that don't belong to a router are automatically added to your sitemap for you. However, since you control what pages are available through your router, you need to create your own sitemap for these router pages. The router sitemap contains all possible URLs that are connected to your router's prefix, so that Google can find each router page. The [`sitemap()`](https://dev.wix.com/docs/velo/api-reference/wix-router/sitemap.md) function handles the SEO and sitemap requests for your router. In the code for your  `sitemap()` function, you need to create and return a [`WixRouterSitemapEntry`](https://dev.wix.com/docs/velo/api-reference/wix-router/wix-router-sitemap-entry.md) object for each router page. This ensures search engines can find the links to your router's pages. As with [SEO for regular pages](https://support.wix.com/en/article/understanding-your-pages-default-seo-settings), you can define the page title, description, and social network images for router pages. The difference is that since router pages don't contain static data, their SEO information must be set dynamically, so they reflect the real content they will hold when they are viewed. Each `WixRouterSitemapEntry` includes information about a page, such as its URL, title, and name. You can also add additional information about each page, such as how often its content changes, when the last change was, and its relative priority within your site. Google uses the sitemap entries to discover all the pages in your router. The `sitemap()` function is also used to populate the items preview widget when you're previewing or editing your site, allowing you to switch between dynamic item pages. ![Items preview widget on Studio](https://wixmp-833713b177cebf373f611808.wixmp.com/images/5e73a3dbd3103e4d592d834bdcaa5c92.png) ## Router data Your `router()` function may send data to the pages it routes to. You can access that data in the frontend page code using the [`getRouterData()`](https://dev.wix.com/docs/velo/api-reference/wix-window-frontend/get-router-data.md) function of the `wix-window-frontend` module. ## See also * [Create a router](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/routers/create-a-router.md) * [About SEO and routing](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/routers/add-seo-to-your-router.md) * [Tutorial: Create dynamic pages with a custom router](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/routers/tutorial-create-dynamic-pages-with-a-custom-router.md) * [About Router Caching](https://dev.wix.com/docs/develop-websites/articles/best-practices/caching/about-router-caching.md) * [wix-router API](https://dev.wix.com/docs/velo/api-reference/wix-router/introduction.md)