Skip to main content

On PageLoad event handler

In order to trigger an action when an application loads, such as fetching data from a database and displaying it in a frontend table, use the on PageLoad event handler.

The on PageLoad event handler allows you to run any Backend API when a user opens or refreshes an Application in Superblocks.

Configure an API to run when the page loads

You can configure a Backend API to run on PageLoad using the API's trigger block as described here.

The list of API triggers and the Page Load settings of a backend API

Run frontend JavaScript when the page loads

You can use the on PageLoad event handler that triggers backend APIs to execute JavaScript on the frontend of your application when a user opens or refreshes it.

  1. Add Backend API, and name it something obvious, in this example on PageLoad. Configure the API trigger block to Always run on page load:

    Adding Backend API and configuring it.
  2. Add a dummy step, in this example Python that runs return True:

    Adding doNothing Python step.
  3. Configure the API response block and then configure the onSuccess event handler to RunJS. This is where we can execute any JavaScript and also many other things when a page loads:

    Configuring response and onSuccess event.