better-auth-protected-routes

Enforce authentication on specified Next.js server-side routes with redirects.

20|3|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill better-auth-protected-routes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-protected-routes
Source: https://github.com/andrelandgraf/fullstackrecipes/tree/main/.agents/skills/better-auth-protected-routes
Command: npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill better-auth-protected-routes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Add server-side route protection to enforce authentication on specific pages while keeping others public.

Core Features & Use Cases

  • Server-side route guards to restrict access on a per-page basis.
  • Seamless integration with existing authentication flows.
  • Supports public and protected routes with minimal configuration.

Quick Start

Fetch the recipe Markdown from the official site and integrate the provided guards to protect selected routes.

Frequently Asked Questions about better-auth-protected-routes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I protect server-side routes in Next.js?

Protect server-side routes in Next.js by adding server-side route guards that enforce per-page authentication checks, restricting access to specified pages while keeping others public.

Can I mix public and protected routes with minimal configuration?

Yes, you can mix public and protected routes with minimal configuration by applying server-side route guards only to specified pages that require authentication, leaving others public.

How do I handle unauthorized access for protected pages?

Handle unauthorized access by configuring the route guards to automatically redirect users away from restricted pages when their session or token authentication fails.

Does this route protection support token-based authentication?

Yes, this route protection supports both session-based and token-based authentication, integrating seamlessly with existing authentication flows to verify user access.

What is the best way to enforce per-page access controls in Next.js?

The best way to enforce per-page access controls in Next.js is using server-side route guards that provide simple configuration for protecting individual pages while supporting existing auth mechanisms.