I'm using the code above to decide where my Login page will redirect to when it is accessed while the user is already logged in.
customElements.whenDefined('router-slot').then(async () => {
const routerSlot = document.querySelector('router-slot');
await routerSlot.add([
{
path: 'menu',
component: () => import('./pages/menu-page'),
guards: [sessionGuard],
},
{
path: 'send-song',
component: () => import('./pages/send-song-page'),
guards: [sessionGuard],
},
{
path: 'vote',
component: () => import('./pages/vote-page'),
guards: [sessionGuard],
},
{
path: 'logout',
component: () => import('./pages/logout-page'),
guards: [sessionGuard],
},
{
path: '',
component: () => import('./pages/login-page'),
},
{
path: '**',
redirectTo: 'menu',
},
]);
});