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.

Was this helpful?