middleware-protection
CommunityCentralized route security for Next.js apps.
Software Engineering#authorization#API security#middleware#Next.js#session management#authenticate#role-based access
Authorjrmatherly
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Protects Next.js routes with a centralized authentication middleware that checks authentication once and supports role-based access control for both pages and API routes.
Core Features & Use Cases
- Declarative route protection for pages and API routes.
- Role-based access control, session refresh, and consistent error handling.
- Use case: protect dashboards, settings, and admin endpoints while exposing public pages.
Quick Start
Copy the middleware.ts into your Next.js project, customize the PROTECTED_ROUTES and PUBLIC_ROUTES arrays, ensure environment variables for your auth provider, and test protected vs public routes.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: middleware-protection Download link: https://github.com/jrmatherly/metorial-workspace/archive/main.zip#middleware-protection Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.