You’re viewing the 2.0 (LTS) docs. View the current 3.0 version of this page.
useKeepSessionAlive hook provides functionality to extend the current user session without requiring re-authentication.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Hook for maintaining active user sessions
useKeepSessionAlive hook provides functionality to extend the current user session without requiring re-authentication.
import { useKeepSessionAlive } from "@getpara/react-sdk";
function SessionManager() {
const { keepSessionAlive, keepSessionAliveAsync, isPending } = useKeepSessionAlive();
const [lastRefresh, setLastRefresh] = useState<Date | null>(null);
const handleKeepAlive = async () => {
try {
const success = await keepSessionAliveAsync();
if (success) {
setLastRefresh(new Date());
console.log("Session extended successfully");
}
} catch (err) {
console.error("Session extension error:", err);
}
};
return (
<button
onClick={handleKeepAlive}
disabled={isPending}
>
{isPending ? "Extending..." : "Extend Session"}
</button>
);
}