Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.15 KB

README.md

File metadata and controls

46 lines (34 loc) · 1.15 KB

@toolsplus/forge-trpc-link

Custom tRPC link to enable tRPC for Atlassian Forge apps.

Installation

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.

Usage

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' 
    }),
  ],
});

customUiBridgeLink options

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;
}