nextjs-better-auth-session-guard

Community

Real-time session invalidation guard for Next.js.

AuthorHankanman
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill ensures that session invalidation in Next.js 16 App Router apps using Better Auth is detected in real time on the client, preventing protected content from remaining visible after sign-out.

Core Features & Use Cases

  • Dual-layer authentication: server-side initial check plus client-side monitoring to detect session changes.
  • Immediate invalidation: redirects when the session becomes invalid, across tabs and after reloads.
  • E2E friendly: supports tests that verify session persistence and sign-out behavior.
  • Seamless UX: preserves return URLs and avoids unnecessary loading spinners.

Quick Start

Integrate a SessionGuard into your protected layout and configure the Better Auth client to poll session state (fetchOnWindowFocus, fetchOnReconnect, refetchInterval) for real-time invalidation.

Dependency Matrix

Required Modules

None required

Components

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: nextjs-better-auth-session-guard
Download link: https://github.com/Hankanman/claude-config/archive/main.zip#nextjs-better-auth-session-guard

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.