> 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 # Method name: beforeRouter(request: WixRouterRequest) # Method package: wixRouter # Method menu location: wixRouter --> beforeRouter # Method Link: https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/before-router.md # Method Description: Registers a hook that is called before a router. The `beforeRouter` hook is a data binding router hook that is triggered before the router with the specified [prefix](#prefixes) has bound the data to the page. The router can be a code router or the data binding router that binds data to a dynamic page. The `beforeRouter()` function is not a function that you call from your code. You define the function in a file named **routers.js** in the Code File's Backend section of the [Velo Sidebar](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/velo-workspace/workspaces/wix-editor-working-with-the-code-sidebar.md). The function is called as described above. Use this hook with a code router to route requests to a different page or return an error response. For example, you can check who is requesting the page and then decide based on the user's role whether to let the router continue to the next step or to return an error type response code. The function receives a [`WixRouterRequest`](wix-router.WixRouterRequest.html) object containing information about the incoming request. The function returns a [`WixRouterResponse`](wix-router.WixRouterResponse.html) object that causes the router to continue its routing, or respond with an HTTP response code. Typically, the response is created using one of the [`next()`](#next), [`forbidden()`](#forbidden), [`notFound()`](#notFound), [`redirect()`](#redirect), or [`sendStatus()`](#sendStatus) functions. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Before router stub ```javascript // In routers.js export function myRouter_beforeRouter(request) { // before router code ... } ``` ## Basic before router hook ```javascript // In routers.js import {forbidden, next} from 'wix-router'; export function myRouter_beforeRouter(request) { if (some_condition) return next(); else return forbidden(); } ``` ## Before router hook that restricts access based on user role ```javascript // In routers.js import {forbidden, next} from 'wix-router'; export function myRouter_beforeRouter(request) { if (request.path.length > 1 && request.path[0] === "admin") { if (request.user && request.user.role == "Admin") return next(); else return forbidden(); } return next(); } ``` ---