naystack - v1.5.10
    Preparing search index...

    Function checkAuthStatus

    • Checks if the current request has a valid refresh cookie. Optionally redirects to a URL if the user is not authorized.

      Use this in Server Components or layouts to gate access.

      Parameters

      • OptionalredirectUnauthorizedURL: string

        If set, redirects to this URL when the user is not authorized.

      Returns Promise<boolean>

      true if authorized. If not authorized and redirectUnauthorizedURL is set, triggers a redirect (never returns).

      // In a Server Component:
      import { checkAuthStatus } from "naystack/auth";
      await checkAuthStatus("/login"); // Redirects to /login if not authenticated