Skip to content

Latest commit

 

History

History
43 lines (23 loc) · 2.54 KB

transition_hooks.md

File metadata and controls

43 lines (23 loc) · 2.54 KB

ILC transition hooks

ILC provides an opportunity to check a route before navigate to it and the only thing that you need to do to handle it is to create ILC transition hooks plugin with the help of ILC plugins SDK to cover any cases that depend on access to any routes.

ILC transition hooks

ILC transition hooks plugin

ILC transition hooks plugin should follow a specific interface that is provided by ILC plugins SDK for this plugin.

ILC gets transition hooks from a plugin and calls them before navigating to a route. It works for CSR and SSR. You have the following several options what to do with a navigation event:

  1. Stop navigation and use your custom behavior such as authentication form as an example to navigate whenever you need then (CSR);
  2. Redirect to a new location (CSR, SSR);
  3. Continue navigation (CSR, SSR).

Every transition hook receives route information (URL, route meta information that a route has in ILC registry) from ILC.

Provided information allows you to handle only specific routes that you need. As an example, you can mark some routes as protected in meta field of a route in ILC registry and do something with navigation to those marked routes.

Route meta field in ILC registry

There is a default ILC transition hooks plugin in ILC plugins SDK that you can use an example.

Server side API

Transition hooks are async on server side.

Every hook receives route information, ILC logger and current request on server side from ILC.

Important! You have to use that provided ILC logger when you need to log something inside of your hook because ILC has own log interface on server side, so every application or plugin should follow it.

Client side API

Transition hooks are sync on client side and ILC calls them per each History change event.

Every hook receives route information and navigate method on client side from ILC.

Important! Whenever you need to navigate to a route from your hook you need to use that provided navigate method to keep ILC SPA routing mechanism safe.

Demo

You can see an example how it works in ILC on our demo website.