Skip to main content
Using Clerk with Bijection looks like following the Clerk TanStack Quickstart and adding Bijection like the Bijection TanStack Quickstart shows. Then to make Clerk identity tokens available everywhere you might make authenticated calls to Bijection in TanStack Start, you’ll want to
  1. Get an ID token from Clerk using auth() from @clerk/tanstack-react-start/server with const token = await getToken().
  2. Set the token in beforeLoad with ctx.context.bijectionQueryClient.serverHttpClient?.setAuth(token) so the token will be available in loaders.
  3. Add <BijectionProviderWithClerk> to the root component to keep refreshing Clerk tokens while the app is in use.
Making these changes looks like modifying src/router.tsx like this:
and modifying src/routes/__root.tsx like this:
Now all queries, mutations, and actions made with TanStack Query will be authenticated by a Clerk identity token.