{"id":48157,"library":"http-rpc","title":"HTTP-RPC","description":"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.","status":"active","version":"2.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/INTUITION-dev/httpRPC","tags":["javascript","RPC","http","JSON-RPC","gRPC","protocol buffers","REST"],"install":[{"cmd":"npm install http-rpc","lang":"bash","label":"npm"},{"cmd":"yarn add http-rpc","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-rpc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used server-side for HTTP requests in Node.js environments","package":"node-fetch","optional":true},{"reason":"Required for JWT token generation and verification if JWT features used","package":"jsonwebtoken","optional":true}],"imports":[{"note":"ESM-only package; must use dynamic import or ESM syntax. The deep import path is required for server-side usage.","wrong":"const Serv = require('http-rpc').Serv","symbol":"Serv","correct":"import { Serv } from 'http-rpc/node-srv/lib/Serv'"},{"note":"Not exported from package root; must use the specific subpath.","wrong":"import { BaseRPCMethodHandler } from 'http-rpc'","symbol":"BaseRPCMethodHandler","correct":"import { BaseRPCMethodHandler } from 'http-rpc/node-srv/lib/Serv'"},{"note":"Client-side import uses a CDN URL; the npm package root does not export a browser-compatible build.","wrong":"import { HttpRPC } from 'http-rpc'","symbol":"HttpRPC (client)","correct":"import { HttpRPC } from 'https://cdn.jsdelivr.net/npm/http-rpc@2.5.0/webApp/httpRPC.min.js'"}],"quickstart":{"code":"// Server-side\nimport { BaseRPCMethodHandler, Serv } from 'http-rpc/node-srv/lib/Serv';\n\nfunction doMultiply(a, b) {\n    return a * b;\n}\n\nclass Handler1 extends BaseRPCMethodHandler {\n    constructor() {\n        super(2, 1); // browser cache 2s, CDN cache 1s\n    }\n    multiply(params) {\n        const a = params.a;\n        const b = params.b;\n        const token = params.token;\n        return [token, doMultiply(a, b)];\n    }\n}\n\nconst service = new Serv(['*']);\nconst h1 = new Handler1();\nservice.routeRPC('api', h1);\nservice.listen(8888);\n\n// Client-side (browser)\nimport { HttpRPC } from 'https://cdn.jsdelivr.net/npm/http-rpc@2.5.0/webApp/httpRPC.min.js';\n\nconst rpc = new HttpRPC('http', 'localhost', 8888);\nconst params = { a: 5, b: 2, token: 'YOUR_JWT_TOKEN' };\nconst [newToken, result] = await rpc.invoke('api', 'multiply', params);\nconsole.log(result); // 10","lang":"typescript","description":"Shows setup of an HTTP-RPC server with a method handler and client-side invocation."},"warnings":[{"fix":"Use: import { Serv, BaseRPCMethodHandler } from 'http-rpc/node-srv/lib/Serv'","message":"Default export is not available; must use deep imports for server code.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use URL: https://cdn.jsdelivr.net/npm/http-rpc@2.5.0/webApp/httpRPC.min.js","message":"Client-side code must be loaded from CDN, not from npm package root.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always call super(browserCacheSeconds, cdnCacheSeconds)","message":"Constructor expects cache parameters; super(cacheBrowser, cacheCDN) not optional.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always return [token, result] from handler methods, even if token is unchanged.","message":"The method signature expects returning an array [token, data] where token is required.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'14.0.0':79 '2.5.1':26 '2023':28 'browser':20,40,62 'browser-to-serv':61 'buffer':88 'built':36 'built-in':35 'cach':39,75 'cdn':42 'client':52 'communic':65 'configur':46 'cor':33,71 'current':22 'design':58 'differenti':57 'edg':38 'fetch':21 'grpc':14,86 'handl':34 'header':76 'http':2,18,82 'http-rpc':1 'idempot':49 'inspir':8 'integr':74 'invoc':55 'javascript':80 'javascript/typescript':5 'json':11,84 'json-rpc':10,83 'jwt':43 'key':56 'librari':7 'minim':67 'node.js':78 'overhead':68 'preflight':70 'protocol':87 'provid':29 'releas':27 'request':72 'requir':77 'rest':89 'rpc':3,6,12,81,85 'server':54,64 'singl':31 'single-trip':30 'specif':59 'stabl':23 'support':45 'timeout':47 'token':44 'trip':32 'version':24 'work':16","created_at":"2026-06-07T16:55:12.344168+00:00","updated_at":"2026-06-07T16:55:12.344168+00:00","problems":[{"fix":"Use: import { Serv } from 'http-rpc/node-srv/lib/Serv'","cause":"Importing from package root instead of deep import path.","error":"Cannot find module 'http-rpc' or its corresponding type declarations."},{"fix":"Use named import: import { HttpRPC } from 'https://cdn.jsdelivr.net/npm/http-rpc@2.5.0/webApp/httpRPC.min.js'","cause":"Using wrong import (e.g., require or default import) for client library.","error":"TypeError: httpRPC.invoke is not a function"},{"fix":"Define an interface for the handler: interface Handler1Type extends BaseRPCMethodHandler { multiply(params: any): [string, any]; }","cause":"TypeScript does not infer methods added via class extension.","error":"Property 'multiply' does not exist on type 'BaseRPCMethodHandler'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/INTUITION-dev/httpRPC","github":"https://github.com/INTUITION-dev/httpRPC","docs":null,"changelog":null,"pypi":null,"npm":"http-rpc","openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}