Skip to main content
Use the react-vite-authkit starter (bijection create --template react-vite-authkit, described in First protected application) as a reference. Its bijection/sign-in.ts configures the WorkOS issuers and keys from WORKOS_CLIENT_ID. Match the configuration to the issuer, audience and JWKS of the token your application receives. In the frontend, create one authkit() adapter for your AuthKitProvider. Wire the provider callbacks and feed the same adapter useAuth() from a component inside the provider. Declare the WorkOS client ID in the frontend’s Vite environment types.
vite-env.d.ts
AuthKit’s useAuth() provides the user and loading state. Its onRefresh callback provides the session and audience evidence in the access token. Forward every callback synchronously if you compose it with your own handler. The adapter supplies no authenticated credential until it has matching evidence. The access token must identify an issuer, subject, and session, and carry an application client ID or an audience. The adapter withdraws watch answers when the token’s issuer, subject, session, application client, audience set, or organization changes. A routine refresh in the same scope preserves the watch. Call auth.clear() before signing out. Create a new adapter and client if you replace the provider. In a server request, create a client with the user’s token using connect(url, { contract: "discover", token }). A verified session identifies the caller. The app’s labels, allow roles and grants control their data access, and its guards can refuse the operations they name. Follow Grants for first-owner and membership setup. The AuthKit notes example declares its owner role in app(tree, { founders }). Choose the founder when creating the installation. After signing in, the founder can invite other members through the app.