Clerk.io Developer Documentation

Welcome to the Clerk.io Developer Documentation.

Here you find our developer documentation for our API and all our SKDs.

Get Started    

Events

How to handle events in Clerk.js.

Events enable you to hook in to the rendering process of Clerk.js.

Event

Fired

after-call

Right after the response has been returned from the Clerk.io API.

before-render

Right before the rendering process begins.

after-render

Right after the rendering process has occurred.

on-error

On any error.

Example use of an event-handler:

<span class="clerk" data-template="@popular-products" data-after-render="logProducts"></span>

<script>
  function logProducts(data) {
    console.log(data.response.result);
  }
</script>

Each event calls the event handler with an event object with the following form:

{
  api: "recommendations/popular",
  args: {
    key: "your_api_key",
    limit: 10,
  },
  template: "#clerk-product-template",
  target: "#popular-products",
  response: {
    "status": "ok",
    "result": [123, 456, ... 890],
    "product_data": [{"id":123,"name":"Lightsaber",... "price":22.00}],...
  }
}
{
  api: ... ,
  args: ... ,
  template: ... ,
  target: ... ,
  response: ...
}

Entry

Content

api

The API endpoint of the request.

args

The parameters of the request.

template

The template to be used.

target

The target where the products will be rendered.

response

The full response object from the API.

Updated 3 years ago

Events


How to handle events in Clerk.js.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.