Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getpara.com/llms.txt

Use this file to discover all available pages before exploring further.

The useKeepSessionAlive hook provides functionality to extend the current user session without requiring re-authentication.

Import

import { useKeepSessionAlive } from "@getpara/react-sdk";

Usage

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>
  );
}