tRPCttRPC
Powered by
Sica / BenS
tRPC•11mo 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
access_token
is only accessible within React land.

Given this, what is the recommended method to include the
access_token
access_token
in the tRPC headers? Can this be achieved using the Singleton Pattern, or is it necessary to use
TRPCProvider
TRPCProvider
instead?
Solution
https://github.com/trpc/trpc/discussions/6508#discussioncomment-12605482
GitHub
Introducing the new TanStack React Query integration · trpc trpc · ...
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...
Jump to solution
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

forwarding headers in solidjs
dionDdion / ❓-help
3y ago
Response headers
peterpPpeterp / ❓-help
4y ago
How to use token in headers() ?
<DxD/><<DxD/> / ❓-help
3y ago