Registry / devops / grpc-express

grpc-express

JSON →
library1.0.1-betajsnpmunverified

An Express middleware that reverse-proxies HTTP 1.1 REST requests into HTTP 2.0 gRPC requests and back, making gRPC services accessible to browsers without additional client or server modifications. Version 1.0.1-beta is the latest and only release. It is Node.js only, supports unary and server-side streaming calls, and requires an existing gRPC client connection. Alternative solutions like gRPC-web require TypeScript or Go, while grpc-express integrates seamlessly with Express apps.

npm install grpc-express
INSTALL
IMPORT
SIG · GRPC-EXPRESS
G
grpc-express
devopsjavascriptv1.0.1-beta
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

grpcExpress
const grpcExpress = require('grpc-express');
import grpcExpress from 'grpc-express';
Package is CommonJS only; ESM import will fail. Use require() or dynamic import.
default
app.use(grpcExpress(grpcClient));
app.use(grpcExpress(grpcClient, {}));
The function expects a single argument (grpcClient). No options object supported.
grpc
const grpc = require('grpc');
import * as grpc from 'grpc';
grpc package is also CommonJS. Ensure you are using @grpc/grpc-js for newer projects; grpc-express may not be compatible.

Set up an Express server that proxies REST requests to a gRPC service using grpc-express middleware.

const grpc = require('grpc'); const grpcExpress = require('grpc-express'); const express = require('express'); const PROTO_PATH = __dirname + '/proto/helloworld.proto'; const hello_proto = grpc.load(PROTO_PATH).helloworld; const grpcClient = new hello_proto.Greeter('localhost:50051', grpc.credentials.createInsecure()); const app = express(); app.use(grpcExpress(grpcClient)); app.listen(3000, () => { console.log('gRPC proxy running on port 3000'); });
Debug
Known issues
breakingPackage only supports unary and server-side streaming calls; bidirectional and client-side streaming are not supported.
fix
Design your gRPC service to avoid bidirectional/client-side streaming endpoints.
affects: <=1.0.1-beta
deprecatedThe 'grpc' npm package is deprecated; use '@grpc/grpc-js' instead.
fix
Replace 'grpc' with '@grpc/grpc-js' and update imports accordingly. Note: grpc-express may not work with @grpc/grpc-js as it relies on grpc.load().
affects: *
gotchaThe middleware auto-generates REST endpoints based on proto package and service names; name collisions or incorrect URLs can occur if multiple services have the same method names.
fix
Ensure proto package and service names are unique to avoid endpoint conflicts.
affects: <=1.0.1-beta
gotchaNo support for request validation, authentication, or rate limiting; implement those in Express middleware before grpc-express.
fix
Add custom middleware before using grpcExpress to handle these concerns.
affects: <=1.0.1-beta
deprecatedgrpc.load() is deprecated; use @grpc/proto-loader for loading .proto files.
fix
Switch to @grpc/proto-loader and loadPackageDefinition to create gRPC clients.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'grpc'
The 'grpc' package is not installed or is deprecated and not installed.
fix
Run: npm install grpc (or switch to @grpc/grpc-js and adjust code accordingly).
TypeError: grpcExpress is not a function
CommonJS import with ES module syntax; package does not support default ESM import.
fix
Use: const grpcExpress = require('grpc-express');
Error: 12 UNIMPLEMENTED: Method not found
The gRPC method name does not match the REST endpoint URL.
fix
Check the proto package/service/method names and ensure the URL matches: /packageName/serviceName/methodName.
Upgrade
Version history
1.0.1-betalatest on npm
Audit
Dependencies
expressrequiredMiddleware framework required to run the middleware.
grpcrequiredOfficial gRPC Node.js library for client-server communication.
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-express — npm install grpc-express · libregistry