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?10 replies