Skip to main content

install_page

Function install_page 

Source
pub fn install_page(
    ctx: &Ctx<'_>,
    page: Arc<Page>,
    async_ctx: AsyncContext,
) -> Result<()>
Expand description

Install the page global when a page is available on the run context.

async_ctx is the AsyncContext driving the script — PageJs captures a clone so page.route(matcher, fn) can dispatch the JS callback back into the same context from a backend route handler (which runs on a separate tokio task, outside the script’s async_with block).

Scripts that do not need browser interaction can run with RunContext.page = None and simply have no page binding.