Checking Session Status
UseisSessionActive()
to verify whether a user’s session is currently valid before performing authenticated operations.
Example usage:
Maintaining Active Sessions
UsekeepSessionAlive()
to extend an active session’s validity without requiring full reauthentication.
Example usage:
Automatic Session Management with React
If you’re using the React SDK and theParaProvider
component, you can leverage automatic session management:
When using the ParaProvider component from the React SDK, it automatically keeps sessions alive in the background by calling
keepSessionAlive()
periodically. You can disable this behavior by setting the disableAutoSessionKeepAlive
prop to true
if you prefer to manage sessions manually.Refreshing Expired Sessions
Para provides therefreshSession()
method when a session has expired.
It’s currently recommended to initiate a full authentication flow rather than using
refreshSession()
when sessions expire. The refresh flow is being improved in upcoming releases.Best Practices
- Proactive Session Management: Always check session status before operations that require authentication
- Regular Session Extension: For long user sessions, periodically call
keepSessionAlive()
or leverage theParaProvider
automatic session management - Graceful Expiration Handling: Provide a smooth re-authentication flow when sessions expire instead of showing errors