App variable not defined in route.js

I created a condition to check on pageInit of the loading the app, but it retuns an error

TypeError: app is undefined.

How do i declare app in route.js, i have tried this

const self = this;
const app = self.$f7;

This is my code.

ROUTES.JS

var routes = [
  {
    path: '/',
    on: {
        pageInit: function (e, page) {
          // do something when page initialized

          const self = this;
          const app = self.$f7;

          localStorage = window.localStorage;

          console.log( localStorage.getItem('onboarding-completed') );

          console.log( localStorage.getItem('user-type') );
          // return false;

          if ( localStorage.getItem('onboarding-completed') == 'true' &&  localStorage.getItem('user-type') == "user" ) {

            var view = app.views.create(".view-main",{
                    url: '/'
                  });

            view.router.navigate('/user-login/')

          }


          if ( localStorage.getItem('onboarding-completed') == 'true' &&  localStorage.getItem('user-type') == "rider" ) {

            var view = app.views.create(".view-main",{
                    url: '/'
                  });

            view.router.navigate('/rider-login/')

          }
        },
      }
  },]

Change

to:

const app = self.app;

Thanks @nolimits4web this is the solution.