Skip to content

Vue Router Guard

The Codedraw client provides an out of the box vue router navigation guard implementation. To install it, add the following code to your main.ts file:

typescript
//...
router.beforeEach(async (to: RouteLocationNormalized) =>
  vulcanSdkStarterClientPlugin.sdk.Authentication
    .vue3RouterGuard(authenticationPlugin.authentication).beforeEach(to as any),
)

The router guard will redirect the user to the login page if the user is not authenticated. If you want any route to be available to unauthenticated users, you can add the meta: { skipAuthentication: true } to the route definition.