Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
firemuzzy opened this issue Dec 23, 2022 · 4 comments

Comments

@firemuzzy
Copy link

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.

@raynirola
Copy link

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.

@klaaz0r
Copy link

klaaz0r commented Jul 6, 2023

@firemuzzy did you manage to solve this?

@seo-ai-team
Copy link

seo-ai-team commented Aug 2, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants