vue-create-protected-routes

Enforce authentication on Vue 3 routes with Vue Router 4 guards.

1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/bmslabs/bmlabs-projects-templates --skill vue-create-protected-routes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue-create-protected-routes
Source: https://github.com/bmslabs/bmlabs-projects-templates/tree/main/view-vuejs/.github/skills/vue-create-protected-routes
Command: npx skills add https://github.com/bmslabs/bmlabs-projects-templates --skill vue-create-protected-routes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Secures client-side navigation by enforcing authentication on protected routes and managing automatic redirects between login and the admin area.

Core Features & Use Cases

  • Meta-driven route protection using requiresAuth and public flags.
  • In-router auth store integration via beforeEach with checkAuthIfNeeded().
  • Smart redirects to login or dashboard to prevent login loops.
  • Lazy loading of protected views to optimize performance.
  • Clear guidance for adding new protected routes in a modular Vue app.

Quick Start

Configure your router to protect sensitive routes and redirect unauthenticated users to the login page automatically.

Frequently Asked Questions about vue-create-protected-routes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I protect routes in Vue 3 and redirect unauthenticated users to login?

Protect Vue 3 routes by adding a requiresAuth meta flag to sensitive views and using a Vue Router 4 beforeEach navigation guard to check authentication. Unauthenticated users are automatically redirected to the login page with a redirect parameter.

How do Vue Router navigation guards interact with Pinia for authentication?

Vue Router navigation guards integrate with Pinia by initializing the auth store inside the beforeEach hook. The router calls a checkAuthIfNeeded function to verify user state before allowing access to protected admin dashboards and nested views.

Can I use Vue Router meta fields to manage public and protected admin views?

Yes, Vue Router meta fields manage access by setting requiresAuth for protected admin views and public flags for open pages. The router reads these meta values during navigation to enforce authentication dynamically across lazily-loaded routes.

What is the best way to prevent login redirect loops in Vue client-side routing?

Prevent login redirect loops in Vue by implementing smart redirects within the router guard. If an authenticated user visits the login page, the guard automatically redirects them to the dashboard, while unauthenticated users are sent to login without looping.

How do I lazy load protected views in a Vue 3 admin dashboard?

Lazy load protected views in Vue 3 by using dynamic imports for your admin dashboard route components. This optimizes performance by loading the code for protected areas only when an authenticated user navigates to them.