Skip to main content

@idhub/identity-adapter-nextjs/server

Interfaces

AnonymousIdCookieStore

Defined in: identity-adapter-nextjs/src/server.ts:13

Structural shape of what Next's cookies() (App Router Server Components, Route Handlers, Server Actions) and request.cookies both return. Typed structurally rather than importing Next's ReadonlyRequestCookies so this module has no value-level dependency on next at all.

Methods

get()

get(name): { value: string; } | undefined

Defined in: identity-adapter-nextjs/src/server.ts:14

Parameters
name

string

Returns

{ value: string; } | undefined

Variables

const DEFAULT_ANONYMOUS_ID_COOKIE_NAME: "_anon_id" = "_anon_id"

Defined in: identity-core/build/esm/index.d.ts:140

Default cookie name for the canonical anonymous id.

Functions

getAnonymousIdFromCookies()

getAnonymousIdFromCookies(cookieStore, config?): AnonymousId | undefined

Defined in: identity-adapter-nextjs/src/server.ts:30

Reads the canonical anonymous id that the middleware already guaranteed.

Intentionally read-only: Server Components cannot set cookies, and the middleware is the single writer on the server side. Returning undefined here means the middleware did not run for this path — check your matcher.

// app/layout.tsx (Server Component)
const anonymousId = getAnonymousIdFromCookies(await cookies())
return <IdentityProvider providers={[...]} initialAnonymousId={anonymousId}>

Parameters

cookieStore

AnonymousIdCookieStore

config?

AnonymousIdCookieConfig = {}

Returns

AnonymousId | undefined


getAnonymousIdFromHeaders()

getAnonymousIdFromHeaders(headers, config?): AnonymousId | undefined

Defined in: identity-core/build/esm/index.d.ts:173

Reads the anonymous id from a Headers object, if present.

Parameters

headers

Headers

config?

AnonymousIdCookieConfig

Returns

AnonymousId | undefined


resolveCookieConfig()

resolveCookieConfig(config?): ResolvedAnonymousIdCookieConfig

Defined in: identity-core/build/esm/index.d.ts:153

Applies the documented defaults from AnonymousIdCookieConfig.

Parameters

config?

AnonymousIdCookieConfig

Returns

ResolvedAnonymousIdCookieConfig

References

AnonymousId

Re-exports AnonymousId


AnonymousIdCookieConfig

Re-exports AnonymousIdCookieConfig