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.
The refresh token string, or null if no refresh cookie is present.
null
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>;} Copy
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>;}
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.