baseUrl


baseUrlstringRead-only

Returns the base URL of the router request.

Premium sites: Premium site baseUrl

Free sites: Free site baseUrl

Note: The above URLs are for a published site. When previewing your site, you will receive the Editor URL.

Get the base URL of the router request
JavaScript
Did this help?

env


envstringRead-only

Returns the current environment the router rendering process is running in.

When possible, the rendering process is split in two in order to improve performance. The first cycle in the process is initiated from backend rendering, and the second cycle is initiated from client-side rendering. Note that even when the rendering cycle is initiated from client-side rendering, router code is called, and router code always runs in the backend.

If not possible on the backend, all rendering is initiated from the client side.

The env property returns "backend" when rendering on the backend, and "browser" when rendering on the client.

Use the env property in your page's onReady() event handler to control where your code runs during the rendering process and to prevent code that causes side effects from running twice.

Note: Rendering never occurs on the backend when previewing your site.

Get the current environment the router request is running in
JavaScript
export function myRouter_Router(request) { let env = request.env; // "backend" }
Did this help?

formFactor


formFactorstringRead-only

Returns the form factor of the device used to make the router request.

Returns either desktop or mobile.

Get the form factor of the device used to make the router request
JavaScript
Did this help?

ip


ipstringRead-only

Returns the remote IP address of the router request.

Get the IP of the router request
JavaScript
Did this help?

pages


pagesArray<string>Read-only

Returns the names of the pages associated with this router.

Pages are added and removed from a router in the Editor. The page names returned by the pages property can be used when returning a router response (e.g. ok('page-name', ...)).

Get the names of the pages associated with this router
JavaScript
Did this help?