Skip to content

Commit f4d8d50

Browse files
committed
Add comments
1 parent 9796608 commit f4d8d50

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/ts/recipe/session/framework/nextjs.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import jose from "jose";
22

33
import SuperTokens from "../../../superTokens";
44

5+
import { isCookiesStore } from "./types";
6+
7+
import type { CookiesStore, CookiesObject, GetServerSidePropsReturnValue } from "./types";
58
import type { AccessTokenPayload, LoadedSessionContext } from "../types";
6-
import { CookiesStore, CookiesObject, GetServerSidePropsReturnValue, isCookiesStore } from "./types";
79

810
const COOKIE_ACCESS_TOKEN_NAME = "sAccessToken";
911
const 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+
**/
1927
export 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+
**/
2336
export async function getSSRSession(cookies: CookiesObject): Promise<GetServerSidePropsReturnValue>;
2437
export async function getSSRSession(
2538
cookies: CookiesObject | CookiesStore,

0 commit comments

Comments
 (0)