# @connectrpc/connect-express

> Connect is a family of libraries for building and consuming APIs on different languages and platforms, and [@connectrpc/connect](https://www.npmjs.com/package/@connectrpc/connect) brings type-safe APIs with Protobuf to TypeScript.

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

## Install

```sh
npm install @connectrpc/connect-express
pnpm add @connectrpc/connect-express
yarn add @connectrpc/connect-express
bun add @connectrpc/connect-express
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-09-07 |
| First published | 2023-08-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 0 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1810 |
| Maintainers | jdailey_buf, tstamm-buf |

## Links

- npm: https://www.npmjs.com/package/@connectrpc/connect-express
- Repository: https://github.com/connectrpc/connect-es
- Homepage: https://github.com/connectrpc/connect-es#readme
- Issues: https://github.com/connectrpc/connect-es/issues
- npm.io page: https://npm.io/package/@connectrpc/connect-express

## Recent versions

- 2.2.0 (latest) — 2026-09-07
- 2.0.0-rc.3 (rc) — 2024-11-05
- 2.0.0-beta.2 (beta) — 2024-10-10
- 2.0.0-alpha.1 (alpha) — 2024-07-01
- 1.4.0-rc1 (next) — 2024-02-05
- 2.1.2 — 2026-06-12
- 2.1.1 — 2025-11-17
- 1.7.0 — 2025-09-08
- 2.1.0 — 2025-08-25
- 2.0.4 — 2025-08-13
- 2.0.3 — 2025-07-25
- 2.0.2 — 2025-02-26
- 2.0.1 — 2025-01-09
- 2.0.0 — 2024-11-19
- 2.0.0-rc.2 — 2024-10-31
- … 18 more at https://npm.io/package/@connectrpc/connect-express/versions

## README

# @connectrpc/connect-express

Connect is a family of libraries for building and consuming APIs on different languages and platforms, and
[@connectrpc/connect](https://www.npmjs.com/package/@connectrpc/connect) brings type-safe APIs with Protobuf to
TypeScript.

`@connectrpc/connect-express` provides a middleware for [Express](https://expressjs.com/), the fast,
unopinionated, minimalist web framework for Node.js

### expressConnectMiddleware()

Adds your Connect RPCs to an Express server.

```ts
// connect.ts
import { ConnectRouter } from "@connectrpc/connect";

export default function (router: ConnectRouter) {
  // implement rpc Say(SayRequest) returns (SayResponse)
  router.rpc(ElizaService, ElizaService.methods.say, async (req) => ({
    sentence: `you said: ${req.sentence}`,
  }));
}
```

```diff
// server.ts
import http from "http";
import express from "express";
+ import routes from "connect";
+ import { expressConnectMiddleware } from "@connectrpc/connect-express";
+ import { createValidateInterceptor } from "@connectrpc/validate";

const app = express();

+ app.use(expressConnectMiddleware({
+  // Validation via Protovalidate is almost always recommended
+  interceptors: [createValidateInterceptor()],  
+  routes
+ }));

http.createServer(app).listen(8080);
```

With that server running, you can make requests with any gRPC-web or Connect client.

`curl` with the Connect protocol:

```bash
curl \
    --header "Content-Type: application/json" \
    --data '{"sentence": "I feel happy."}' \
    http://localhost:8080/connectrpc.eliza.v1.ElizaService/Say
```

Node.js with the gRPC-web protocol (using a transport from [@connectrpc/connect-node](https://www.npmjs.com/package/@connectrpc/connect-node)):

```ts
import { createClient } from "@connectrpc/connect";
import { createGrpcWebTransport } from "@connectrpc/connect-node";
import { ElizaService } from "./gen/eliza_connect.js";

const transport = createGrpcWebTransport({
  baseUrl: "http://localhost:8080",
  httpVersion: "1.1",
});

const client = createClient(ElizaService, transport);
const { sentence } = await client.say({ sentence: "I feel happy." });
console.log(sentence); // you said: I feel happy.
```

A client for the web browser actually looks identical to this example - it would
simply use `createConnectTransport` from [@connectrpc/connect-web](https://www.npmjs.com/package/@connectrpc/connect-web)
instead.

Note that Express does not support the Node.js `http2` module. You can serve the
Connect protocol and gRPC-Web with Express, but not gRPC.

## Getting started

To get started with Connect, head over to the [docs](https://connectrpc.com/docs/node/getting-started)
for a tutorial, or take a look at [our example](https://github.com/connectrpc/connect-es/tree/main/packages/example).

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