trpc-chrome icon indicating copy to clipboard operation
trpc-chrome copied to clipboard

Question: do you have a recommendation on how to use trpc-chrome with a trpc web server

Open firemuzzy opened this issue 2 years ago • 4 comments

Hi @jlalmes, love the idea of having a typesafe communication with background thread.

I am trying to figure out the best way to update my extension to use TRPC throughout. trpc-chrome will give me type safe content scripts to background communication, but I also have the background script communicating with a trpc api server.

Do you have a recommendation on the best way to do this, other than creating another TRPC client in the background tab to make calls to the server? I am trying to avoid duplication but can't think of another way to proxy the call through the background script to the api to preserver the types.

firemuzzy avatar Dec 23 '22 21:12 firemuzzy

Best way achieve this is to use monorepo and import router definition from api server in extension. Here is a simple pnpm workspace monorepo, you can replace packages/website with extension.

raynirola avatar Dec 27 '22 03:12 raynirola

@firemuzzy did you manage to solve this?

klaaz0r avatar Jul 06 '23 15:07 klaaz0r

Best way achieve this is to use monorepo and import router definition from api server in extension. Here is a simple pnpm workspace monorepo, you can replace packages/website with extension.

This isn't what the question is about. The problem is that there is now a second hop before the backend server.

The structure looks like this and IDK what the best setup for it is. Start in content script -> go to background script -> make API call to the backend Backend response -> background script -> response in content script

seo-ai-team avatar Aug 02 '23 21:08 seo-ai-team

Looked into this a bit. I'd love if ChromeHandler had the ability to take another link as a parameter, something like HttpBatchLink. That way we can specify what backend URL we would want to eventually ping

seo-ai-team avatar Aug 03 '23 13:08 seo-ai-team