@@ -2,8 +2,10 @@ import jose from "jose";
22
33import SuperTokens from "../../../superTokens" ;
44
5+ import { isCookiesStore } from "./types" ;
6+
7+ import type { CookiesStore , CookiesObject , GetServerSidePropsReturnValue } from "./types" ;
58import type { AccessTokenPayload , LoadedSessionContext } from "../types" ;
6- import { CookiesStore , CookiesObject , GetServerSidePropsReturnValue , isCookiesStore } from "./types" ;
79
810const COOKIE_ACCESS_TOKEN_NAME = "sAccessToken" ;
911const HEADER_ACCESS_TOKEN_NAME = "st-access-token" ;
@@ -16,10 +18,21 @@ type SSRSessionState =
1618 | "tokens-do-not-match"
1719 | "tokens-match" ;
1820
21+ /**
22+ * Function signature for usage with Next.js App Router
23+ * @param cookies - The cookies store exposed by next/headers (await cookies())
24+ * @param redirect - The redirect function exposed by next/navigation
25+ * @returns The session context value or directly redirect the user to either the login page or the refresh API
26+ **/
1927export async function getSSRSession (
2028 cookies : CookiesStore ,
2129 redirect : ( url : string ) => never
2230) : Promise < LoadedSessionContext > ;
31+ /**
32+ * Function signature for usage with getServerSideProps/Next.js Pages Router
33+ * @param cookies - The cookie object that can be extracted from context.req.headers.cookie
34+ * @returns A props object with the session context value or a redirect object
35+ **/
2336export async function getSSRSession ( cookies : CookiesObject ) : Promise < GetServerSidePropsReturnValue > ;
2437export async function getSSRSession (
2538 cookies : CookiesObject | CookiesStore ,
0 commit comments