Custom tRPC link to enable tRPC for Atlassian Forge apps.
npm install @toolsplus/forge-trpc-link
Note that this package has a peer dependency on @forge/bridge
. If you have not installed @forge/bridge
you may install before installing this package.
You can import and add the customUiBridgeLink
to the links array as follows:
import { createTRPCProxyClient } from '@trpc/client';
import { customUiBridgeLink } from '@toolsplus/forge-trcp-link';
import type { HelloRouter } from '../my-trpc-server';
const client = createTRPCProxyClient<HelloRouter>({
links: [
customUiBridgeLink({
resolverFunctionKey: 'rpc'
}),
],
});
The customUiBridgeLink
function takes an options object that has the CustomUiBridgeLinkOptions
shape.
interface CustomUiBridgeLinkOptions {
/**
* Key of the Forge resolver function that handles tRPC
* requests from this link.
*
* @defaultValue 'rpc'
*/
resolverFunctionKey?: string;
}