A JavaScript/TypeScript RPC library inspired by JSON-RPC and gRPC that works over HTTP with browser fetch(). Current stable version is 2.5.1 (released 2023). Provides single-trip CORS handling, built-in edge caching (browser and CDN), JWT token support, configurable timeout and idempotency, and both client and server invocation. Key differentiators: designed specifically for browser-to-server communication with minimal overhead, no preflight CORS requests, and integrated caching headers. Requires Node.js >=14.0.0.
npm install http-rpcNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows setup of an HTTP-RPC server with a method handler and client-side invocation.
Use: import { Serv, BaseRPCMethodHandler } from 'http-rpc/node-srv/lib/Serv'Use URL: https://cdn.jsdelivr.net/npm/http-rpc@2.5.0/webApp/httpRPC.min.js
Always call super(browserCacheSeconds, cdnCacheSeconds)
Always return [token, result] from handler methods, even if token is unchanged.
Use: import { Serv } from 'http-rpc/node-srv/lib/Serv'Use named import: import { HttpRPC } from 'https://cdn.jsdelivr.net/npm/http-rpc@2.5.0/webApp/httpRPC.min.js'Define an interface for the handler: interface Handler1Type extends BaseRPCMethodHandler { multiply(params: any): [string, any]; }