Skip to content

Using keycloak inside vue router #4

@aminmc

Description

@aminmc

Hello

I'm new to Vue 3 and I'm trying to integrate this library with my vue application. I'm using vue router and I need access to the keycloak attributes from the useKeycloak() hook. For example:

const routes = [
    {
        path: '/',
        name: 'Dashboard',
        component: Dashboard,
    },
    {
        path: "/:catchAll(.*)",
        redirect: '/'
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes,
});


router.beforeEach((to, from, next) => {
    next();

});
export default router

What I'd like to do is do some additional checks before sending to the actual route. What is the best way to access the keycloak object within the beforeEach? I've tried using the useKeycloak() but the data isn't available.

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions