Auth Guard: Role-Based Route Protection for Next.js 16
Next.js 16 role-based auth in one file. RBAC, auto token refresh, cross-tab sync, proxy-based route protection. Prevents common hydration errors, zero additional runtime dependencies.
shubhra.dev
Loading...
8 snippets with this tag
Next.js 16 role-based auth in one file. RBAC, auto token refresh, cross-tab sync, proxy-based route protection. Prevents common hydration errors, zero additional runtime dependencies.
Stop fighting connection drops. A WebSocket hook with automatic reconnection, heartbeat keep-alive, offline message queue, auth token injection, and send with acknowledgment all in one file.
A zero-dependency React hook for infinite scroll. Intersection Observer, AbortController-safe reset, smart retry, and React 18+ Strict Mode support.
Three React hooks for debouncing values, API queries, and form inputs. Leading/trailing edge control, maxWait burst protection, works with TanStack Query and React Hook Form out of the box. Only imports React. Nothing else.
Stop losing user data. A React Hook Form auto-save hook with debounce, offline queue, retry with exponential backoff, localStorage crash recovery, version tracking, and Zod validation. One hook. One file.
A zero-dependency React toast system. Five types, six positions, promise toasts, pause-on-hover, dark mode, and correct ARIA per notification type.
A React code block component that strips shell prompts and line numbers before copying. Fixed-position tooltips, keyboard accessible, SSR-safe, HTTP fallback.
A single-file React live code editor. Five themes, line numbers, SSR-safe fallback, scoped style isolation, copy/reset, and noInline auto-detection.