Get started
Install the Bijection CLI and create a new app withbijection init, choosing the react-vite or nextjs template:
Option 1: use a Bijection-managed WorkOS team
Permissions: provisioning the Bijection-managed WorkOS team, disconnecting it,
inviting WorkOS team members, and creating/deleting shared project-level
WorkOS environments all require team admin (or project admin, for the
project-level operations). Provisioning a WorkOS environment for an individual
deployment uses the same permission as managing that deployment, so any team
member can self-serve a WorkOS env for their dev/preview deployment but only
admins can do so for production.
What if I already have a WorkOS team but want to use the Bijection-managed features?
What if I already have a WorkOS team but want to use the Bijection-managed features?
If you you are an existing WorkOS user but want the Bijection auto-configuration
and auto-provisioning support, you’ll need to start with a new WorkOS team
that is managed by Bijection. To do that, make sure you select an email address
that isn’t already associated with a WorkOS team when prompted. The email
address will need to be linked with your Bijection account. You can
link additional email addresses to your
Bijection account in the console. Depending on your email provider, you might be
able to use a
+ address for this step (e.g. your.name+workos@example.com) to
avoid having to create an entirely new email account.If using an existing WorkOS team is more important than the
auto-provisioning and auto-configuration support, you should exit out of the
prompt flow triggered by npm run dev and follow along with
the section below instead. Just note that using an existing
team means that Bijection won’t be able to auto-configure new applications or
auto-provision WorkOS environments for each of your deployments.Option 2: use an existing WorkOS team
When you are prompted to create a new WorkOS team, choose No. You’ll then need to manually configure your Bijection deployment and client framework.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 deployment
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
Syncing data and handling events using the WorkOS Component
You can integrate the WorkOS Component into your application to sync user data into your application and handle other events (like account lifecycle) from WorkOS.Accessing user information in functions
See Auth in Functions to learn about how to access information about the authenticated user in your queries, mutations and actions. 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/auth.config.ts.
As long as you followed the instructions for
adding AuthKit to an existing Bijection app, your
bijection/auth.config.ts file will make use of the WORKOS_CLIENT_ID value
referenced below.
Sample auth.config.ts
Sample auth.config.ts
bijection/auth.config.ts
WORKOS_CLIENT_ID environment
variable to your development WorkOS Client ID.
Then, to switch your deployment to the new configuration, run bijection dev.
Production configuration
In the left sidenav of the Bijection console,
switch to your production deployment and set the WORKOS_CLIENT_ID environment
variable to your production WorkOS Client ID.
Then, to switch your deployment to the new configuration, run
bijection deploy.
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
The authentication flow looks like this under the hood:- The user clicks a login button
- The user is redirected to a page where they log in via whatever method you configure in AuthKit
- After a successful login AuthKit redirects back to your page, or a different page which you configure via .
- The now knows that the user is authenticated.
- The fetches an auth token from AuthKit.
- The
BijectionReactClientpasses this token down to your Bijection backend to validate - Your Bijection backend retrieves the public key from AuthKit to check that the token’s signature is valid.
- The
BijectionReactClientis notified of successful authentication, and now knows that the user is authenticated with Bijection.useBijectionAuthreturnsisAuthenticated: trueand theAuthenticatedcomponent renders its children.