# grpc-gcp

> Extension for supporting Google Cloud Platform specific features for gRPC.

Latest version **1.1.1** (published 2026-07-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install grpc-gcp
pnpm add grpc-gcp
yarn add grpc-gcp
bun add grpc-gcp
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-07-16 |
| First published | 2018-11-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 2 |
| Unpacked size | 131 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Google Inc. |
| Maintainers | google-wombot |
| Keywords | google, grpc, cloud, gcp |

## Links

- npm: https://www.npmjs.com/package/grpc-gcp
- Repository: https://github.com/GoogleCloudPlatform/grpc-gcp-node
- Homepage: https://github.com/GoogleCloudPlatform/grpc-gcp-node#readme
- Issues: https://github.com/GoogleCloudPlatform/grpc-gcp-node/issues
- npm.io page: https://npm.io/package/grpc-gcp

## Dependencies (2)

- [protobufjs](https://npm.io/package/protobufjs.md) ^7.6.3
- [@grpc/grpc-js](https://npm.io/package/@grpc/grpc-js.md) ^1.7.0

## Recent versions

- 1.1.1 (latest) — 2026-07-16
- 1.0.1 — 2023-01-25
- 1.0.0 — 2022-09-14
- 0.4.2 — 2022-04-18
- 0.4.1 — 2022-04-06
- 0.3.3 — 2020-07-08
- 0.3.2 — 2020-04-24
- 0.3.1 — 2020-04-22
- 0.3.0 — 2020-04-03
- 0.1.1 — 2018-11-16
- 0.1.0 — 2018-11-02

## README

# gRPC-GCP for Node.js

A Node.js module providing grpc supports for Google Cloud APIs.

## Installation

```sh
npm install grpc-gcp --save
```

## Usage

Let's use Spanner API as an example.

First, Create a json file defining API configuration, with ChannelPoolConfig and MethodConfig.

```json
{
  "channelPool": {
    "maxSize": 10,
    "maxConcurrentStreamsLowWatermark": 1
  },
  "method": [
    {
      "name": [ "/google.spanner.v1.Spanner/CreateSession" ],
      "affinity": {
        "command": "BIND",
        "affinityKey": "name"
      }
    },
    {
      "name": [ "/google.spanner.v1.Spanner/GetSession" ],
      "affinity": {
        "command": "BOUND",
        "affinityKey": "name"
      }
    },
    {
      "name": [ "/google.spanner.v1.Spanner/DeleteSession" ],
      "affinity": {
        "command": "UNBIND",
        "affinityKey": "name"
      }
    }
  ]
}
```

Load configuration to ApiConfig.

```javascript
// @grpc/grpc-js can be used in place of grpc with no changes
var grpc = require('grpc');
var grpcGcp = require('grpc-gcp')(grpc);
var fs = require('fs');

var apiDefinition = JSON.parse(fs.readFileSync('your_api_config_json_file'));
var apiConfig = grpcGcp.createGcpApiConfig(apiDefinition);
```

Pass `gcpChannelFactoryOverride` and `gcpCallInvocationTransformer` to channel options when initializing api client.

```javascript
var channelOptions = {
  channelFactoryOverride: grpcGcp.gcpChannelFactoryOverride,
  callInvocationTransformer: grpcGcp.gcpCallInvocationTransformer,
  gcpApiConfig: apiConfig,
};

var client = new SpannerClient(
  'spanner.googleapis.com:443',
  channelCreds,
  channelOptions
);
```

## Build from source

Download source.

```sh
git clone https://github.com/GoogleCloudPlatform/grpc-gcp-node.git && cd grpc-gcp-node
```

```sh
git submodule update --init --recursive
```

Build grpc-gcp.

```sh
npm install
```

## Test

Setup credentials. See [Getting Started With Authentication](https://cloud.google.com/docs/authentication/getting-started) for more details.

```sh
export GOOGLE_APPLICATION_CREDENTIALS=path/to/key.json
```

Run unit tests.

```sh
npm test
```

Run system tests.

```sh
npm run system-test
```

---
_Source: https://npm.io/package/grpc-gcp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
