Skip to content

VexSessionAdapterProvider

VexSessionAdapterProvider(props): Element

Defined in: packages/react/src/auth/VexSessionAdapterContext.tsx:101

Mounts the client session adapter for useCanAccessAdminPanel to read on public pages. Mount once, at the app root, beside VexConfigProvider — the same root VexConfigProvider already carries access to every route, public and admin alike (P-004); this is the matching bridge for user.

ReactNode

The subtree that should see it — the whole app, so every public-page header can gate on useCanAccessAdminPanel.

VexSessionAdapter

The session adapter to provide.

Element

The context provider wrapping props.children.

// ~/components/providers/client.tsx ("use client")
import { VexSessionAdapterProvider, VexConfigProvider } from "@vexcms/react";
import { useSession } from "~/auth/client";
import config from "~/vex.config";
function ClientProviders({ children }: { children: React.ReactNode }) {
return (
<VexSessionAdapterProvider
value={{
useSession: () => {
const { data, isPending } = useSession();
return { user: data?.user ?? null, isPending };
},
}}
>
<VexConfigProvider config={config}>{children}</VexConfigProvider>
</VexSessionAdapterProvider>
);
}