One-click install
npx skills add https://github.com/lespaceman/athena-workflow-marketplace --skill router-core-auth-and-guards-lespaceman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/auth-and-guards
Source: https://github.com/lespaceman/athena-workflow-marketplace/tree/main/plugins/tanstack-start/skills/upstream/%40tanstack/router-core/skills/router-core/auth-and-guards
Command: npx skills add https://github.com/lespaceman/athena-workflow-marketplace --skill router-core-auth-and-guards-lespaceman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Protect TanStack Router apps by enforcing auth checks before route loading and redirect logic, so protected content is never shown before authentication decisions.

Core Features & Use Cases

  • BeforeLoad guards to block unauthenticated users
  • Redirects and isRedirect handling for safe navigation
  • RBAC with roles and permissions across nested routes
  • Inline login layouts and Auth provider integrations (Auth0, Clerk, Supabase)
  • Router context to share auth state across loaders and components
  • Works with authenticated layouts and nested routes for admin dashboards and restricted sections

Quick Start

Add a beforeLoad guard to protect routes and redirect unauthenticated users to /login.

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 guard routes in TanStack Router to block unauthenticated users?

Guard TanStack Router routes by adding a beforeLoad check to block unauthenticated users. This intercepts navigation to enforce auth decisions before route loading, ensuring protected content is never rendered until the auth provider resolves the session state.

How does isRedirect handling work for safe navigation to login pages?

isRedirect handling catches redirect errors thrown during beforeLoad checks, allowing safe navigation to login pages. This mechanism prevents unhandled rejection errors when routing unauthenticated users away from protected admin dashboards.

Can I implement RBAC with roles and permissions across nested routes?

Yes, you can implement RBAC with roles and permissions across nested routes. The beforeLoad guard evaluates user roles from the router context to restrict access to specific admin dashboards and user areas based on assigned permissions.

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

Yes, the auth guard integrates with Auth0, Clerk, and Supabase. It connects the auth provider to the router context, sharing the authentication state consistently across loaders and components throughout the client-side application.

What is the best way to share auth state across loaders and components in TanStack Router?

The best way to share auth state is using the router context. Storing the auth provider session in the router context exposes consistent authentication data to both beforeLoad guards and nested route components.