{"id":48101,"library":"grpc-xhr","title":"grpc-xhr","description":"A lightweight JavaScript library for making AJAX requests to gRPC-web or gRPC Gateway endpoints from the browser. Current stable version is 1.0.13 with low release cadence (last release 2023). Provides a simple Promise-based interface for streaming and unary gRPC calls over XHR, without requiring gRPC-web or a service worker. Smaller bundle size compared to gRPC-web client, but limited to browser environments and lacks advanced features like client-side interceptors or metadata manipulation.","status":"active","version":"1.0.13","language":"javascript","source_language":"en","source_url":"https://github.com/appscode/grpc-xhr","tags":["javascript","grpc","protobuf","xhr"],"install":[{"cmd":"npm install grpc-xhr","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-xhr","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-xhr","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Protobuf message serialization/deserialization.","package":"google-protobuf","optional":false},{"reason":"Polyfill for fetch API needed in older browsers (optional if fetch is natively supported).","package":"whatwg-fetch","optional":true}],"imports":[{"note":"Package supports only ESM imports. CommonJS require will result in errors.","wrong":"const GrpcXhr = require('grpc-xhr')","symbol":"default","correct":"import GrpcXhr from 'grpc-xhr'"},{"note":"Named export for the client class. Default export is the factory function, not the class.","wrong":"import GrpcXhrClient from 'grpc-xhr'","symbol":"GrpcXhrClient","correct":"import { GrpcXhrClient } from 'grpc-xhr'"},{"note":"Utility function to create a configured client. ESM only; no CommonJS support.","wrong":"const { grpcXhrFactory } = require('grpc-xhr')","symbol":"grpcXhrFactory","correct":"import { grpcXhrFactory } from 'grpc-xhr'"}],"quickstart":{"code":"import GrpcXhr, { GrpcXhrClient } from 'grpc-xhr';\n\nconst client = new GrpcXhrClient({\n  baseURL: 'https://api.example.com',\n  headers: { 'X-API-Key': process.env.API_KEY ?? '' }\n});\n\n// Unary call\nconst request = { name: 'Alice' };\nvoid client.unary('/myapp.MyService/GetUser', request)\n  .then(response => console.log(response))\n  .catch(err => console.error(err));\n\n// Server streaming\nconst stream = client.stream('/myapp.MyService/ListUsers', {});\nfor await (const chunk of stream) {\n  console.log(chunk);\n}","lang":"typescript","description":"Shows how to create a gRPC XHR client and perform unary and streaming requests."},"warnings":[{"fix":"Use import syntax and ensure your environment supports ES modules.","message":"Package is ESM-only since v1.0.0. Do not use require().","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"For streaming, verify your gRPC-Gateway configuration returns response immediately.","message":"The client does not support gRPC-web trailers. Use unary calls only for non-streaming endpoints.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use google-protobuf for message encoding/decoding. Do not mix with @grpc/grpc-js.","message":"The package recommends google-protobuf, but @grpc/grpc-js is not supported for proto marshalling.","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Initialize client with { baseURL, headers } directly; no nested 'options' key.","message":"In v1.0.0, the constructor signature changed; previous options format is invalid.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.13':27 '2023':34 'advanc':75 'ajax':10 'base':40 'browser':22,71 'bundl':60 'cadenc':31 'call':47 'client':67,79 'client-sid':78 'compar':62 'current':23 'endpoint':19 'environ':72 'featur':76 'gateway':18 'grpc':2,14,17,46,53,65,86 'grpc-web':13,52,64 'grpc-xhr':1 'interceptor':81 'interfac':41 'javascript':6,85 'lack':74 'last':32 'librari':7 'lightweight':5 'like':77 'limit':69 'low':29 'make':9 'manipul':84 'metadata':83 'promis':39 'promise-bas':38 'protobuf':87 'provid':35 'releas':30,33 'request':11 'requir':51 'servic':57 'side':80 'simpl':37 'size':61 'smaller':59 'stabl':24 'stream':43 'unari':45 'version':25 'web':15,54,66 'without':50 'worker':58 'xhr':3,49,88","created_at":"2026-06-07T16:54:55.876679+00:00","updated_at":"2026-06-07T16:54:55.876679+00:00","problems":[{"fix":"Replace const GrpcXhr = require('grpc-xhr') with import GrpcXhr from 'grpc-xhr'.","cause":"Using CommonJS require instead of ESM import.","error":"ReferenceError: require is not defined"},{"fix":"Use import { grpcXhrFactory } from 'grpc-xhr'.","cause":"Mistaking default export for named export.","error":"TypeError: grpcXhrFactory is not a function"},{"fix":"Ensure baseURL is a valid absolute URL (e.g., https://example.com).","cause":"Missing baseURL or incorrect URL format.","error":"Uncaught (in promise) TypeError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL"}],"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/appscode/grpc-xhr#readme","github":"https://github.com/appscode/grpc-xhr","docs":null,"changelog":null,"pypi":null,"npm":"grpc-xhr","openapi_spec":null,"status_page":null,"smithery":null,"categories":["api-client"],"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}}