@gopherium/react-auth
v0.8.0
Published
Session authentication for React apps backed by gouncer's authkit.
Readme
@gopherium/react-auth
Session authentication for React apps backed by gouncer's authkit.
Entry points
@gopherium/react-authis the headless core: the auth API client,useSession,useLogout,sessionQueryKey, the slot-basedAuthGate,createAuthQueryClient, andisSessionRevoked.@gopherium/react-auth/adminis the user administration API client.@gopherium/react-auth/wpdsrenders the WordPress Design System UI:LoginScreen(brand prop),AccountPanel,UsersScreen,NewUserScreen, andusersNavItem. Import@gopherium/react-auth/wpds/style.cssalongside it.@gopherium/react-auth/testingis the msw harness:server,installTestEnvironment,seedSession,defaultUser, and canned handlers for the auth endpoints.
Mount
const client = createAuthQueryClient()
<QueryClientProvider client={client}>
<AuthGate loginScreen={(onLogin) => <LoginScreen brand="MyApp" onLogin={onLogin} />}>
<App />
</AuthGate>
</QueryClientProvider>Consumer requirements
reactand@tanstack/react-queryare peer dependencies; the app must own exactly one copy of each. With workspace or linked installs, add both to your bundler's dedupe list.- The client calls same-origin
/api/auth/*and/api/userspaths. In development, proxy/apito your backend so the__Host-session cookie is first-party. /wpdsneeds the@wordpress/uipeer and, on React 19, a@wordpress/elementpatch stubbing the react-dom exports React 19 removed. Seepatches/in this package's repository directory.
License
Apache-2.0. Copyright © 2026 Manuel 'SirLouen' Camargo.
