ILC allows you to check a route before navigating to it.
To handle it, you need to create an ILC transition hooks plugin using the ILC plugins SDK{: target=_blank} :octicons-link-external-16: to cover cases that depend on accessing any route.
ILC transition hooks plugin should follow a specific interface{: target=_blank} :octicons-link-external-16: that the ILC plugins SDK{: target=_blank} :octicons-link-external-16: provides for this plugin.
ILC gets transition hooks from the plugin and calls them before navigating a route. It works for both SSR and CSR.
There are the following options to handle the navigation event:
- Stop navigation and use your custom behavior such as authentication form as an example to navigate whenever you need (CSR).
- Redirect to a new location (CSR, SSR).
- Continue navigation (CSR, SSR).
From ILC, every transition hook receives route information (URL, route meta information that a route has in the ILC registry).
The provided route information allows you to handle only the routes that you need. For example, in the ILC Registry, you can mark some routes as protected in the Metadata field, and handle navigation to those marked routes as required.
!!! example "Example of the default ILC transition hooks plugin" Check an example of the default ILC transition hooks plugin{: target=_blank} :octicons-link-external-16: in ILC plugins SDK{: target=_blank} :octicons-link-external-16:
Transition hooks are asynchronous on the server-side.
From ILC, every hook receives route information, ILC logger, and the current request on the server-side.
!!! warning "" You have to use the ILC logger when you need to log inside of your hook. ILC has its own log interface on the server-side, so every application or plugin should follow it.
Transition hooks are synchronous on the client side. ILC calls them on each History change event.
From ILC, every hook receives route information and navigate method on the client-side.
!!! warning "" Whenever you need to navigate to a route from your hook, you need to use that provided navigate method to keep the ILC SPA routing mechanism safe.
Check the demo website{: target=_blank} :octicons-link-external-16: to see how hooks work in ILC.