Hi Dark Beccio,
Take my apologies for the late reply.
You can use the templateApplied setting of the Smart.Router and with it you can run the javascript each time the template is applied.
I have made a little code snippet on how to achieve this:
//In your JS file

window.onload = function () {
    const router = new JQX.Router('mainView', './');
        { path: '/', template: 'homeTemplate', title: 'Home' },
        { path: '/about', template: 'aboutTemplate', title: 'About',},
        { path: '/contacts', template: 'contactsTemplate', title: 'Contacts' }
    router.templateApplied = viewChanged;
    function viewChanged(route) {
    const path = route.path;
        if (path == '/about'){
            alert('The route is: '+ path)

Note that for base for this code snippet I have used the example from the documentation about the Router.
Here is a link for it: https://www.htmlelements.com/docs/router/
Please, do not hesitate to contact us if you have any additional questions.
Best regards,
Yavor Dashev
Smart UI Team