naystack - v1.5.10
    Preparing search index...

    Function getRefreshToken

    • Reads the refresh token from cookies (server-side only). Use this in Server Components, layouts, or Server Actions to check if the user is authenticated.

      Returns Promise<string | null>

      The refresh token string, or null if no refresh cookie is present.

      import { getRefreshToken } from "naystack/auth";
      import { redirect } from "next/navigation";

      export default async function ProtectedLayout({ children }: { children: React.ReactNode }) {
      const token = await getRefreshToken();
      if (!token) return redirect("/login");
      return <div>{children}</div>;
      }