Get started
Install the Bijection CLI, then create a starter:bijection dev to configure the
backend and start the app. Development registers each assigned app origin and
/callback URL. Managed publication binds the target’s public AuthKit client ID
and configures its assigned origins before activation. Provider secrets remain in
the target’s private environment.
For an existing app, follow Add to Existing App,
then run bijection dev.
The private notes example
shows how to use AuthKit with a label and a scoped grant for each signed-in author.
For email-bound invitations, use the shared
verified email setting.
To connect WorkOS, follow the instructions in one of the sections below.
Option 1: use a Bijection-managed WorkOS team
A Bijection team Admin can create the managed WorkOS team. Developers and Admins can create the WorkOS environment for a deployment they can deploy to. Provision the environment withbijection installation workos provision and
read the public client ID with bijection installation workos status. Add
that ID to the tree’s issuer.authkit declaration. The deployment’s WorkOS
API key remains with the managed installation. Configure the frontend
origin, redirects and CORS in WorkOS.
If the management service reports that managed authentication is unavailable,
configure an existing WorkOS team.
What if I already have a WorkOS account?
What if I already have a WorkOS account?
A managed team is a new WorkOS team whose administrator is the verified email
you signed in with. If WorkOS already has an account for that email, or it
administers another Bijection team’s managed WorkOS team,
provision-team
can’t create the team; follow
Option 2 instead. With your existing team,
Bijection doesn’t create WorkOS environments for your installations: you create
them in WorkOS and set their credentials yourself.Option 2: use an existing WorkOS team
Configure your Bijection deployment and client framework yourself.1
Find your WorkOS Client ID and API Key
From the WorkOS dashboard get started page under Quick start, find your
WORKOS_CLIENT_ID and WORKOS_API_KEY.2
Set the values in your installation
Use the
bijection CLI to set environment variables for WORKOS_CLIENT_ID
and WORKOS_API_KEY with values from the WorkOS dashboard in the previous step.3
Deploy your application
Run
bijection dev to automatically sync your configuration to your backend.For multiple Bijection applications integrated with an existing WorkOS team
you’ll need to decide if the single-tenant or multi-tenant
model
is right for your situation. That may include manually provisioning additional
WorkOS environments.
Next steps
Accessing user information in functions
See Auth in Functions to learn about how to access information about the authenticated user in your queries and mutations. See Storing Users in the Bijection Database to learn about how to store user information in the Bijection database.Accessing user information client-side
To access the authenticated user’s information, use AuthKit’sUser object,
which can be accessed using AuthKit’s
useAuth()
hook. For more information on the User object, see the
WorkOS docs.
components/Badge.tsx
Configuring dev and prod instances
To configure a different AuthKit instance between your Bijection development and production deployments, you can use environment variables configured on the Bijection console and referenced inbijection/sign-in.ts.
As long as you started from bijection create or the instructions for
adding AuthKit to an existing Bijection app, your
bijection/sign-in.ts file will make use of the WORKOS_CLIENT_ID value
referenced below.
Sample issuer declaration
Sample issuer declaration
bijection/sign-in.ts
WORKOS_CLIENT_ID environment variable to your development WorkOS
Client ID.
Put the same public client ID in a JSON file as
{"WORKOS_CLIENT_ID":"client_…"}. Run
bijection check --write-lock --definition-inputs public-inputs.json, review the
issuer entries, then run bijection dev.
Production configuration
In the deployment switcher at the top of the Bijection
console, switch to your production deployment
and set the WORKOS_CLIENT_ID environment variable to your production WorkOS
Client ID.
Include both client IDs in the allowed oneOf set and derive the lock with the production client ID using the same
bijection check --write-lock --definition-inputs public-inputs.json workflow. Deploy the reviewed
lock with bijection deploy. The running installation switches issuers when the
deploy activates.
Configuring WorkOS AuthKit’s API keys
WorkOS AuthKit’s API keys differ depending on whether they are for development or production. Don’t forget to update the environment variables in your.env
file as well as your hosting platform, such as Vercel or Netlify.
Development configuration
WorkOS API Key for development follows the format sk_test_.... WorkOS Client
ID for development follows the format client_01....
.env.local
sk_live_.... WorkOS Client ID
for production follows the format client_01....
.env
Under the hood
Your identity provider issues the application token. The frontend’s auth adapter (authkit(), clerk() or bijectionAuth() from
@bijectionhq/bijection/client) hands it to the client made with
connect(url, { token: auth }), which asks for the current token
on every request and live connection. The deployment verifies the token
against bijection/sign-in.ts before admitting a call. The roles the
caller holds, the labels they clear and the app’s guards then decide what the
call may do.