Skip to content

feat: Add documentation for proactive token refresh and session-only auth #2273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tusharpandey13
Copy link
Contributor

@tusharpandey13 tusharpandey13 commented Aug 13, 2025

This PR enhances the examples to include patterns for proactive token refresh and session-only authentication. It also clarifies important considerations for refresh token rotation.

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

Fixes: #2149

📋 Changes

These changes provide developers with more advanced and robust patterns for handling tokens and sessions. The proactive refresh example helps prevent API call failures due to expired tokens in latency-sensitive applications.

  • Changed EXAMPLES.md: Added a note on getSession usage, a warning about refresh token rotation, and a new example for proactive token refresh. Corrected the import path for withPageAuthRequired.
  • Changed README.md: Fixed minor list formatting.

🎯 Testing

Manual:

  1. Review the new documentation in EXAMPLES.md.
  2. Check the new sections on getSession, refresh token rotation, and proactive token refresh for clarity and accuracy.
  3. Verify the code examples are correct and easy to understand.

@tusharpandey13 tusharpandey13 requested a review from a team as a code owner August 13, 2025 17:03
@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.39%. Comparing base (ea75860) to head (c4c3add).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2273   +/-   ##
=======================================
  Coverage   85.39%   85.39%           
=======================================
  Files          26       26           
  Lines        2471     2471           
  Branches      462      462           
=======================================
  Hits         2110     2110           
  Misses        355      355           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -162,6 +162,9 @@ export default function Profile() {

On the server, the `getSession()` helper can be used in Server Components, Server Routes, and Server Actions to get the session of the currently authenticated user and to protect resources, like so:

> [!NOTE]
> The `getSession()` method is perfect for applications that only need user identity information without calling external APIs. It provides access to the user's profile data from the ID token without requiring access tokens, making it ideal for session-only authentication patterns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't getSession return the RT and AT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4: Advanced auth scenarios (token renewal, session management, parallel requests)
3 participants