router-core/auth-and-guards

Protect TanStack Router routes with beforeLoad guards and RBAC.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/abereghici/skills --skill router-core-auth-and-guards-abereghici
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/auth-and-guards
Source: https://github.com/abereghici/skills/tree/main/skills/tanstack-router/auth-and-guards
Command: npx skills add https://github.com/abereghici/skills --skill router-core-auth-and-guards-abereghici

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide provides patterns for securing routes in TanStack Router apps, including beforeLoad guards, redirect-based flows, inline login, RBAC, and provider integration, ensuring authenticated access and consistent router context.

Core Features & Use Cases

  • Protect routes using beforeLoad guards and redirect-based authentication flows to prevent unauthorized access.
  • Support inline login, RBAC with roles/permissions, and auth-provider integration (Auth0, Clerk, Supabase) across protected layouts and nested routes.
  • Share auth state via router context to maintain a seamless authentication experience across route boundaries.

Quick Start

Configure a protected route tree using a beforeLoad guard, a redirect-based login flow, and an authenticated layout to enforce RBAC and provider integration.

Frequently Asked Questions about router-core/auth-and-guards

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

FAQPage Schema
How do I protect routes with beforeLoad guards in TanStack Router?

You can protect routes in TanStack Router by applying beforeLoad guards to verify authentication and RBAC permissions, redirecting unauthorized users to login flows before the route renders.

What is the best way to implement RBAC with roles and permissions in TanStack Router?

Implementing RBAC in TanStack Router involves configuring router context to propagate auth state and applying beforeLoad guards to check user roles and permissions across protected layouts and nested routes.

Does this auth pattern work with providers like Auth0, Clerk, and Supabase?

Yes, the beforeLoad guard pattern supports auth provider integration with Auth0, Clerk, and Supabase to manage authenticated access and share auth state via router context across route boundaries.

How do I configure router context to share auth state across nested routes?

Configuring router context in TanStack Router allows you to propagate auth state across nested routes, maintaining a seamless authentication experience and enabling consistent access control checks.

Can I use inline login instead of redirect-based authentication flows?

Yes, this approach supports both redirect-based authentication and inline login patterns, allowing you to choose the access control flow that best fits your protected route requirements.