{"repo":"chaqchase/next-middleware-toolkit","free":true,"listed":false,"github":"https://github.com/chaqchase/next-middleware-toolkit","clone":"git clone https://github.com/chaqchase/next-middleware-toolkit.git","description":"A powerful, type-safe middleware system for Next.js","language":"TypeScript","stars":12,"topics":["middleware","middlewares","next-auth","nextjs","protected-routes","routes"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"next-middleware-toolkit A simple, type-safe middleware system for Next.js with route protection and built-in authentication rules. Features - Type-Safe : Full TypeScript support with excellent IntelliSense - Simple API : Intuitive fluent interface for building middleware - Route Protection : Easy-to-use route guards with exact and prefix matching - Built-in Rules : Common authentication and authorization patterns included - Flexible : Create custom rules for any use case - Lightweight : No dependencies beyond Next.js Installation Quick Start API Reference MiddlewareBuilder The main class for building middleware. Constructor Options Methods .exact(path, ...rules) Add an exact route match. The path must match exactly for the rules to execute. .prefix(path, ...rules) Add a prefix route match. Any path starting with the prefix will match. .build() Build and return the final middleware handler. Built-in Rules All built-in rules are available via the Rules object. Rules.isLoggedIn() Requires the user to be logged in. Redirects to /sign-in if not authenticated. Rules.isNotLoggedIn() Requires the user to NOT be logged in. Redirects to / if already authenticated. Rules.hasRole(role) Requires the user to have a specific role. Returns 403 if the user doesn't have the required role. Works with both user.role (string) and user.roles (array). Rules.hasPermission(permission) Requires the user to have a specific permission. Returns 403 if the user doesn't have the required permission. Requir","default_branch":null,"files":null,"tree":[],"storefront":"/r/chaqchase","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/chaqchase/next-middleware-toolkit/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}