06-authentication-flow

Implement frontend session lifecycle with hydration, logout, and 401 handling.

Updated Mar 9, 2026
One-click install
npx skills add https://github.com/kennypallchizaca-coder/agentic-full-stack-skills --skill 06-authentication-flow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 06-authentication-flow
Source: https://github.com/kennypallchizaca-coder/agentic-full-stack-skills/tree/main/frontend-skills/06-authentication-flow
Command: npx skills add https://github.com/kennypallchizaca-coder/agentic-full-stack-skills --skill 06-authentication-flow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Frontend apps often struggle with a portable, end-to-end session lifecycle that survives page reloads, handles token expiry gracefully, and coordinates protected navigation without leaking provider wiring into UI layers.

Core Features & Use Cases

  • Session lifecycle orchestration: restore and maintain session state across app boot, navigation, and reloads.
  • Hydration and logout routines: centralized startup hydration and a single logout flow reused by guards and error handling.
  • Boundary separation: keeps provider wiring in Skill 11 and route protection in Skill 12 to maximize portability.

Quick Start

Use this skill to implement a portable frontend session flow by scaffolding an auth repository, a global session store, and a startup hydration/logout pattern aligned to your framework.

Frequently Asked Questions about 06-authentication-flow

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

FAQPage Schema
How do I manage SPA authentication state across page reloads?

Manage SPA authentication state across reloads by scaffolding an auth repository and a global session store with unknown, authenticated, and guest states. Implement a centralized startup hydration routine to restore the session lifecycle on boot.

What is the best way to handle token expiry and 401 errors in a frontend SPA?

Centralize frontend session management by implementing a unified 401 handling path and a single logout routine reused by route guards and error handlers. This prevents scattered logout logic across your SPA or hybrid app.

How do I structure an auth repository for login and logout flows?

Structure an auth repository for login and logout flows by defining login, logout, me, and refresh methods. Bind this repository to a global session store to orchestrate state transitions without leaking provider wiring into UI layers.

Can I use this session management approach with any frontend framework?

You can apply this session management approach across frameworks by maintaining strict boundary separation. Keep provider wiring and route protection in distinct modules to maximize portability for protected dashboards and startup hydration.

How do I hydrate an authenticated session on SPA startup?

Hydrate an authenticated session on SPA startup by running a centralized initialization routine that calls the auth repository's me method. This updates the global session store from an unknown state to authenticated or guest before rendering.

Why should I separate session state from route protection logic?

Separate session state from route protection logic to maintain architectural boundaries and maximize portability. Keeping route protection distinct prevents leaking authentication provider wiring directly into your UI and navigation layers.