MCPcopy
hub / github.com/nextauthjs/next-auth / useState

Function useState

src/core/lib/oauth/state-handler.ts:45–63  ·  view source on GitHub ↗
(
  state: string | undefined,
  options: InternalOptions<"oauth">
)

Source from the content-addressed store, hash-verified

43 * and clears the container cookie afterwards.
44 */
45export async function useState(
46 state: string | undefined,
47 options: InternalOptions<"oauth">
48): Promise<{ value: string; cookie: Cookie } | undefined> {
49 const { cookies, provider, jwt } = options
50
51 if (!provider.checks?.includes("state") || !state) return
52
53 const value = (await jwt.decode({ ...options.jwt, token: state })) as any
54
55 return {
56 value: value?.state ?? undefined,
57 cookie: {
58 name: cookies.state.name,
59 value: "",
60 options: { ...cookies.pkceCodeVerifier.options, maxAge: 0 },
61 },
62 }
63}

Callers 7

oAuthCallbackFunction · 0.90
sign-in.test.jsFile · 0.85
sign-out.test.jsFile · 0.85
SessionFlowFunction · 0.85
CSRFFlowFunction · 0.85
ProvidersFlowFunction · 0.85
PageFunction · 0.85

Calls

no outgoing calls

Tested by 3

SessionFlowFunction · 0.68
CSRFFlowFunction · 0.68
ProvidersFlowFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…