Closed sleaper closed 1 year ago
I'm just stupid. You can get sender from ctx like this:
createChromeHandler({
router: appRouter,
createContext: (ctx) => {
return { sender: ctx.req.sender }
}
})
Then you can get ctx in your procedure like this:
const appRouter = t.router({
helloTab: t.procedure.input(z.object({ url: z.string().url() })).mutation(async ({ input, ctx }) => {
//@ts-ignore
const tab = ctx.sender.tab
console.log(tab)
}),
});
Is there any way how to get the sender from tRPC procedure? I need it to get a tab.
Here is an example with onMessage listener: