middleware-protection
Installation
SKILL.md
Middleware Protection
Comprehensive route protection and authorization patterns for Clerk middleware in Next.js applications. Provides middleware configuration, route matchers, role-based access control, and authentication boundaries.
Core Concepts
Middleware Architecture
- Edge Runtime: Clerk middleware runs on Cloudflare Workers/Vercel Edge
- Request Interception: Middleware executes before route handlers
- Auth State: Access to authentication state via
auth()helper - Matcher Patterns: Configure which routes middleware applies to
Route Protection Levels
- Public Routes: Accessible without authentication (sign-in, sign-up, landing pages)
- Protected Routes: Require authentication (dashboards, user profiles)
- Organization Routes: Require organization membership
- Role-Based Routes: Require specific roles or permissions