Sica / BenS
tRPC10mo ago
9 replies
Sica / Ben

Auth Headers in Singleton Pattern

The recommended approach for setting up a SPA with tRPC is to use the Singleton Pattern (source). However, many authentication libraries rely on providers and hooks to supply the authenticated user, meaning the access_token is only accessible within React land.

Given this, what is the recommended method to include the access_token in the tRPC headers? Can this be achieved using the Singleton Pattern, or is it necessary to use TRPCProvider instead?
Solution
GitHub
We are excited to announce the new TanStack React Query integration for tRPC is now available on tRPC's next-release. Compared to our classic React Query Integration it's simpler and more T...
Was this page helpful?